css-grid

Fill grid container so that last grid item area is always filled

筅森魡賤 提交于 2020-01-01 17:17:13
问题 Right now I have a grid with 1 row and 5 columns , which I'm going to be using for navigational links, but there's a chance that on some pages the grid container might not have 5 children. The issue is that grids begin filling from the first available area. Is there any way to fill the grid container with grid items so that instead the last area is always filled? For example... [a][b][c][d][ ] should be [ ][a][b][c][d] [a][b][c][ ][ ] should be [ ][ ][a][b][c] Notably, I do not want to

Fill grid container so that last grid item area is always filled

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-01 17:17:11
问题 Right now I have a grid with 1 row and 5 columns , which I'm going to be using for navigational links, but there's a chance that on some pages the grid container might not have 5 children. The issue is that grids begin filling from the first available area. Is there any way to fill the grid container with grid items so that instead the last area is always filled? For example... [a][b][c][d][ ] should be [ ][a][b][c][d] [a][b][c][ ][ ] should be [ ][ ][a][b][c] Notably, I do not want to

How can I control the number of items per column in flexbox?

瘦欲@ 提交于 2020-01-01 10:48:05
问题 In a flex container I have 5 items with a column direction but in a certain width I want to display 3 per column and force the others to wrap is there any way to do that without fixed height ? my code : <div class="container"> <div class="item-1 item">Item 1</div> <div class="item-2 item">Item 2</div> <div class="item-3 item">Item 3</div> <div class="item-4 item">Item 4</div> <div class="item-5 item">Item 5</div> </div> .container { display: flex; flex-flow: column wrap; } @media (min-width:

CSS Grid Row Height Safari Bug

我们两清 提交于 2020-01-01 04:27:08
问题 I've made a grid template with rows of 1fr 1fr 1fr. In the middle row, there are a list of inline images. In Chrome and Firefox, the images respect the height of the grid row and adapt properly. However, in Safari 10.1.2 and Safari TP 31, there appears to be a combination of the images overflowing the row and not scaling the image widths appropriately. Perhaps I'm doing something wrong? Or is this a Safari bug? And if so, is there a workaround? Safari 10.1 Safari TP Chrome 60 #grid { height:

Why auto-fit or auto-fill not working properly with minmax?

旧巷老猫 提交于 2020-01-01 03:45:12
问题 It doesn't work properly when I add auto-fit or auto-fill instead of a number. grid-template-columns: repeat(auto-fit, minmax(max-content, max-content)); But it works properly when I add number instead of max-content. grid-template-columns: repeat(auto-fit, minmax(50px, max-content)); But I want the size of the grid to be the same(be fit) as the size of the content. Like this: grid-template-columns: repeat(30, minmax(max-content, max-content)); (using auto-fit or auto-fill). How can I do that

CSS grid height wrong when using percent as grid gap

╄→гoц情女王★ 提交于 2019-12-31 03:24:15
问题 I'm using a CSS grid with images in it and wanted to set a gap between elements that scales with the size of the grid. So I set the grid-gap to 2%, but doing that caused the grid height to be wrong, and caused the grid contents to overlap with the next element below. Using other units as the grid-gap , like vw works fine. If I want to use a percentage as the gap, how can I fix the overlap problem? Here's a minimal reproduction of the issue I'm running into: .grid { display: grid; grid

CSS grid height wrong when using percent as grid gap

和自甴很熟 提交于 2019-12-31 03:24:09
问题 I'm using a CSS grid with images in it and wanted to set a gap between elements that scales with the size of the grid. So I set the grid-gap to 2%, but doing that caused the grid height to be wrong, and caused the grid contents to overlap with the next element below. Using other units as the grid-gap , like vw works fine. If I want to use a percentage as the gap, how can I fix the overlap problem? Here's a minimal reproduction of the issue I'm running into: .grid { display: grid; grid

Width of widest element sets width of all siblings in the row

瘦欲@ 提交于 2019-12-31 01:49:07
问题 I've read a lot of tutorials about CSS flex boxes and CSS grids, but frankly I just can't figure out how to do this simple(?) thing. All I want is for the elements in a container to all be as wide as the widest element. I don't want them to fill up the whole width of the container, just all grow to the maximum width. Can that be done with CSS? Consider this HTML: <div class="container"> <button>a normal button</button> <button>tiny</button> <button>a really, really, really wide button</button

How to calc() the number of rows in a grid template?

末鹿安然 提交于 2019-12-30 19:04:11
问题 I'd like to calculate the number of rows in a grid template using calc() , but trying to get the repeat count with division isn't working: .grid { display: grid; grid-gap: 10px; grid-template-columns: 1fr; margin-bottom: 10px; background: rgba(0, 0, 0, 0.2); } .grid>div { background: tomato; width: 20px; text-align: center; margin: auto; } .grid.no-calc { grid-template-rows: repeat(3, 30px); } .grid.addition { grid-template-rows: repeat(calc(1 + 2), 30px); } .grid.subtraction { grid-template

How can I have a sticky footer with my CSS Grid layout?

不羁岁月 提交于 2019-12-29 07:30:32
问题 I found this CodePen solution for a sticky footer in a CSS Grid layout, but it has two problems for me: It is kinda ugly with min-height: 100% and height: 100% It only works with two elements in the body (a div and a footer) I need something that works with this HTML structure: <body> <nav>Some navigation buttons</nav> <main>The content</main> <footer>Copyrights and stuff</footer> </body> I don't really want to pack the <nav> and the <main> into a <div> , and I would love to do this in pure