css-grid

How come minmax(0, 1fr) works for long elements while 1fr doesn't?

馋奶兔 提交于 2019-11-26 12:30:28
So I have this grid: +---------+------------------------------+---------+ | <div> | <p> - 1000 characters long | <div> | +---------+------------------------------+---------+ Inside p there's super long string with no spaces. div s are placeholders with fixed dimensions. This produces the above: display: grid; grid-auto-flow: column; grid-template-columns: auto minmax(0, 1fr) auto; But changing minmax(0, 1fr) to 1fr gives this: +---------+----------------------------------------+ | <div> | <p> - 1000 characters long | <div> | +---------+----------------------------------------+ It overflows out

Make row stretch across all columns in CSS Grid

自作多情 提交于 2019-11-26 11:39:01
问题 I\'ve been having trouble getting my nav to stretch across my columns completely, despite the fact that I\'ve specified what columns I wanted the nav to stretch over, if you could take a look at my code and point out my error that would be awesome. Here\'s an image of the HTML file in browser body { margin: 0; padding: 0; } .container { max-width: 960px; width: 100%; margin: 0 auto; display: grid; grid-template-columns: 4fr 1fr; grid-template-rows: 50px auto; } .mainnav { grid-column: 1 / 2;

Why does CSS Grid layout add extra gaps between cells?

风流意气都作罢 提交于 2019-11-26 11:23:47
问题 Can’t figure out why CSS grid layout adds an unwanted extra space to content around the vertical cells, though margin and padding are zeroed out: .grid { display: grid; grid-template-columns: 13fr 11fr 4fr 20fr; grid-auto-rows: 12fr; grid-gap: 4px; align-items: center; } .grid figure { outline: 1px solid red; margin: 0; padding: 0; } .grid figure img { margin: 0; padding: 0; width: 100%; display: block; } .grid .gi13x12 { grid-column-start: 1; grid-column-end: 2; grid-row-start: 1; grid-row

Make a grid item span to the last row / column

自作多情 提交于 2019-11-26 11:23:27
Is it possible to make a grid item span from the first to the last row when I don't know the number of rows? Lets say I have the following html with an unknown number of boxes. How can I make the third .box span from the first grid-line to the last? .container { display: grid; grid-template-columns: repeat(3, minmax(10rem, 1fr)) [last-col] 35%; grid-template-rows: auto [last-line]; } .box { background-color: blue; padding: 20px; border: 1px solid red; } .box:nth-child(3) { background-color: yellow; grid-column: last-col / span 1; grid-row: 1 / last-line; } <div class="container"> <div class=

How to get grid items of different lengths to wrap?

眉间皱痕 提交于 2019-11-26 09:59:02
问题 With the repeat() and auto-fit / auto-fill functions it\'s easy to get grid items to wrap when there is a defined length pattern for the columns or rows . In the example below, all columns are a minimum width of 100px and maximum width of 1fr. jsFiddle demo #grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); grid-gap: 1em; } #grid > div { background-color: #ccddaa; padding: 10px; } <div id=\"grid\"> <div></div> <div></div> <div></div> <div></div> <div></div>

How to make images stay within the rows of a css grid container?

我的未来我决定 提交于 2019-11-26 09:58:56
问题 The code below shows the intended behavior when I resize the window in Chrome 60, and in Firefox 55 (but not in iOS Safari 10.3; that is most likely another question why it misbehaves in Safari). html, body { width: 100%; height: 100%; padding: 0; margin: 0; border: 0; background-color: lightgrey; } .container { box-sizing: border-box; width: 100%; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: repeat(3, calc((60vh - 12px)/3)); /*grid-template-rows: 1fr 1fr 1fr;*/ /*grid

What are the areas covered by Flexbox which are difficult or impossible to achieve with Grid?

三世轮回 提交于 2019-11-26 08:57:13
问题 It is wildly highlighted that Flexbox is for 1-D and Grid for 2-D but I have not found a clear explanation why Grid could not be used for 1-D and replace Flexbox. The closest I came to is But you could also argue that purely 1D layout like this is more powerful in Flexbox, because Flexbox allows us to move those elements around easier (e.g. move them all to one side or another, change their order, space them out evenly, etc). I use Grid and Flexbox for basic layout: a general placement of the

Percentage padding / margin on grid item ignored in Firefox

扶醉桌前 提交于 2019-11-26 08:38:58
问题 This codepen creates a grid of red cells 100*50 px on Chrome. This is the expected behavior. #grid{ display: grid; grid-gap: 8px; grid-template-columns: 100px 100px; } .cell{ background-color: red; padding-bottom: 50%; } <div id=\"grid\"> <div class=\"cell\"></div> <div class=\"cell\"></div> <div class=\"cell\"></div> <div class=\"cell\"></div> <div class=\"cell\"></div> <div class=\"cell\"></div> </div> Firefox 52 completely ignores the padding-bottom: 50%; and I don\'t know why. I can\'t

minmax() defaulting to max

妖精的绣舞 提交于 2019-11-26 08:38:03
问题 I tried to set minmax() for the grid-template-rows and interestingly enough, the outcome was that grid-rows extended to the max of the minmax() instead of min. How could we make grid rows stay at the minimum declared size, and later if more content is added - the grid row would expand to the maximum declared size and not more? Here is an example: body { background: gray; border: solid black 1px; display: grid; grid-template-columns: 1fr 2fr 1fr; grid-template-rows: minmax(50px, 150px); }

CSS only solution to set MULTIPLE “same height” row sections on a responsive grid

瘦欲@ 提交于 2019-11-26 08:28:28
问题 Wanted : a CSS only solution to enable MULTIPLE equal height grid \"sections\" on a per row basis, that is also responsive. Note: this is a follow-up question to this question which has only a single \"equal height\" section per item - which can be achieved through flexbox The below diagram should help explain the requirement: The \"item grid\" should be responsive - in that it can show a different number of cards per row based on viewport width (4 on desktop, 2 on mobile). Within a given row