css-grid

css grid problem with background and wrapping

余生长醉 提交于 2019-11-29 15:56:41
I have a grid where I want it to work somewhat like it is except when there are only 1 or 2 cells I want it to auto size and not be a set of 3 with the last one holding its cell space. When I set repeat(3, 100px) value to auto-fit then it kills the column layout. I still need it to wrap at 3. .parent { background: #f4f4f5; font-size:2em; border: 1px solid black; padding: 20px 0; text-align: center; width: 100%; } .parent .wrapper { display: inline-grid; grid-template-columns: repeat(3, 100px); box-shadow: 1px 0px 5px 0px rgba(0,0,0,0.75); grid-auto-flow: row; background-color: white; } .cell {

How to limit the amount of columns in larger viewports with CSS Grid and auto-fill/fit?

做~自己de王妃 提交于 2019-11-29 15:33:41
I'm starting to work with CSS Grid, I've been reading about the properties to help with responsiveness; so I'm trying to build a small grid with 6 elements; my intention is for them to show as 2 rows on larger devices like this: And also to show them all stacked on smaller devices,so everything is good regarding the smaller devices, I'm using auto-fill so it stays responsive, however if I the view the page on a laptop screen or desktop it is able to fill one more column and ends up looking like this: This is my grid layout code. display: grid; grid-template-columns: repeat(auto-fill, 260px);

How to hide implicit grid rows?

Deadly 提交于 2019-11-29 14:48:37
The snippet below uses CSS Grid to increase the number of columns for wide containers. For narrow containers (e.g. uncomment width: 80vw or resize the example), it adds implicit rows (only 2 are explicit in the grid-template-rows property). How can I maintain only 2 rows, making the grid items that "overflow" the 2-by-n grid hidden? .wrapper { border: 2px solid #f76707; background-color: #fff4e6; display: grid; /* width: 80vw; */ grid-template-columns: repeat(auto-fill, 200px); grid-template-rows: repeat(2, 1fr); } .wrapper > div { border: 2px solid #ffa94d; border-radius: 5px; background

In CSS Grid why is 1FR+9FR not behaving the same as 10FR in small screen sizes?

别说谁变了你拦得住时间么 提交于 2019-11-29 14:15:26
So I am defining a layout in CSS Grid which needs this particular row to have identically sized inputs. I can do the math and just specify percentages and it works fine (see commented out line) but when I specify it via the fractional unit (fr) then the spanned column "squishes" more than the non-spanned columns. .A { grid-area: a; } .B { grid-area: b; } .C { grid-area: c; } .Exchange_Row { display: grid; grid-template-columns: 1fr 9fr 10fr 10fr 1fr; /* grid-template-columns: 3% 27% 30% 30% 3%; */ grid-template-areas: "a a b c ." } input[type=text] { border: solid; } <div style="width: 90%;

How do you collapse unused row in a CSS grid?

荒凉一梦 提交于 2019-11-29 13:36:40
So I have a simple stack of three paragraphs on mobile that I want to style in a grid on larger viewports, without changing the source order. The first section might have anything from several lines to no content at all. In this case, how do I make the first row collapse so the second row fills the space? IE when the top section is empty, the last section should appear at the top .grid { display: grid; grid-template-rows: min-content auto; grid-template-columns: 60% 40%; grid-template-areas: "main first" "main last"; } .first { grid-area: first; } .main { grid-area: main; } .last { grid-area:

Are there selectors that target elements in certain grid positions?

不羁的心 提交于 2019-11-29 13:21:02
I have a CSS grid with a bunch of auto-flowed grid items. Sometimes the grid items are one 1 x 1 track, and sometimes they're 2 x 2 tracks, so I do not know from the source order which items will be in certain positions in the grid . This means that styling with :nth-child() will not be reliable. I would like to add styling to items in certain grid columns, (mostly the last column). Is there a CSS selector that will let me style these items? For example, in this demo, how would I style boxes 3, 5, and 9, ( codepen here )? .grid-container { display:grid; grid-template-columns: 1fr 1fr 1fr; grid

Named CSS grid lines with SCSS

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 12:28:37
问题 I'm experimenting with the new CSS Grid Layout system in codepen.io. It has an interesting feature called named grid lines that allows defining custom names for the grid lines between the columns and rows. Unfortunately I can't seem to get the feature to work because SCSS doesn't approve of the [line-name] syntax. #container.named { grid-template-columns: [main-start] 100px [content-start] 1fr [content-end] 100px [main-end]; // Will not pass SCSS validation :( .one { grid-column: content

Make a grid column span the entire row

随声附和 提交于 2019-11-29 12:11:59
问题 Imagine we have 2 CSS Grid containers with dynamic columns count based on width . display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); The grid works perfectly, but what if we need to have another grid to have the 1st column to be same as in another grid with the code shown above, but it's another column to span through more cells - depending on how many cells are in the current row. To better understand issue, there are images: On more narrow wrapper: We would need to

CSS grids: align square cells with container edges with consistent grid gap?

时间秒杀一切 提交于 2019-11-29 11:04:55
The goal is to align square cells with their container's leading and trailing edges while achieving a consistent gap between cells on each row, and between each row. This Codepen is close, but there are two problems: (1) vertical gaps are different from horizontal gaps; and (2) the squares are flush with the leading edge, but not the trailing edge. https://codepen.io/anon/pen/wREmjo ul { display: grid; width: 260px; grid-template-columns: repeat(auto-fit, minmax(40px, 1fr)); grid-auto-rows: 1fr; grid-gap: 10px; list-style-type: none; border: 2px solid black; box-sizing: border-box; margin: 0;

minmax fails (invalid property value)

你离开我真会死。 提交于 2019-11-29 11:03:59
Chrome gives an invalid property value and doesn't respect the CSS: grid-template-columns: repeat(auto-fill, minmax(auto, 1fr)); It also fails when auto is replaced with min-content and max-content . It works as expected when auto is replaced by a fixed value e.g. grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); This is surprising because both repeat and minmax support the keywords. The html is simple <div class='wrapper> <div>...</div> <div>...</div> </div> and css .wrapper { display: grid grid-template-columns: repeat(auto-fill, minmax(auto, 1fr)); } When using auto-fill or auto