
Summmary of:
1. https://www.theodinproject.com/lessons/node-path-intermediate-html-and-css-advanced-grid-properties
2. https://www.theodinproject.com/lessons/node-path-intermediate-html-and-css-using-flexbox-and-grid
❗ resize: both allows users to resize the container by clicking and dragging
❗ overflow: auto enable scrolling if we resize the container to be smaller than our grid can accommodate
.grid-container {
grid-template-rows: repeat(2, 150px);
grid-template-columns: repeat(5, 150px);
}
.grid-container {
grid-template-rows: repeat(2, 1fr);
grid-template-columns: repeat(5, 1fr);
}
fr : a way of distributing whatever remaining space is left in the grid fr resize according to resize: both.grid-container {
grid-template-rows: repeat(2, min(200px, 50%));
grid-template-columns: repeat(5, max(120px, 15%));
}
50% of the grid’s total vertical space (because we are defining a row size), unless that number would exceed 200px120px and 15% of the grid container’s width. In doing so, we are essentially setting a minimum width of our grid column size at 120px..grid-container {
grid-template-columns: repeat(5, minmax(150px, 200px));
}
150px, stops growing at 200pxclamp(minimum-size, ideal-size, maximum-size)
.simple-example {
width: clamp(500px, 80%, 1000px);
}
1000px, 80% of the number would be 800px but it will stay as 500px.simple-example {
display: grid;
width: 1000px;
grid-template-columns: repeat(auto-fit, 200px);
}
The width is 1000px and we are telling it to fill in columns with tracks of 200px each. As long as there are at least five grid items, this will result in a 5-column layout no matter what.
.grid-container {
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
auto-fit will return the highest positive integer without overflowing the grid.500px wide, our grid will render 3 columns. Once the browser has determined how many columns we can fit, it then resizes our columns up to the maximum value allowed by our minmax() function.1fr, so all three columns will be given an equal allotment of the space available. As we resize our window, these calculations happen in realtime.auto-fitauto-fit will keep the grid items at their max size.auto-fill, the grid items will snap back down to their min size once the space becomes available to add another grid item, even if there isn’t one to be rendered.max and snapping back to their min as the grid expands and more room becomes available for new grid tracks.In Layout First Design, use Grid.
- In Layout First Design, you decide how you want the pieces arranged, then fill in the content. That is when Grid shines. Defining grid row and column tracks gives you full control of layout. Content in a grid can only fill the spaces of explicit or implicit tracks. So, when you have an idea of how the big picture of a container should look like, Grid is the clear choice.