curriculum/challenges/english/blocks/review-css-grid/671a99394bedfb9a5bc687c4.md
display property to grid..container {
display: grid;
}
fr (Fractional) Unit: This unit represents a fraction of the space within the grid container. You can use the fr unit to create flexible grids.column-gap property to create gaps between columns. You can use the row-gap property to create gaps between rows. Or you can use the gap shorthand property to create gaps between both rows and columns.grid-template-columns: This is used to set lines names and sizing for the grid track columns..container {
display: grid;
width: 100%;
grid-template-columns: 30px 1fr;
}
grid-template-rows: This is used to set lines names and sizing for the grid track rows.grid-auto-flow: This determines how auto-placed items fit in the grid..container {
display: grid;
width: 100%;
grid-auto-flow: column;
}
grid-auto-columns: This is used to set the size for columns created implicitly..container {
display: grid;
width: 100%;
grid-auto-columns: auto;
}
place-items: This is used to align items for both block and inline directions.align-items: This is used to set the alignment for the items in a grid container.repeat() Function: This function is used to repeat sections in the track listing. Instead of writing grid-template-columns: 1fr 1fr 1fr; you can use the repeat() function instead..container {
display: grid;
grid-template-columns: repeat(3, 1fr);
}
grid-template-columns or grid-template-rows properties.minmax() Function: This function is used to set the minimum and maximum sizes for a track..container {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-auto-rows: minmax(150px, auto);
}
grid-column-start and grid-row-start properties. To specify where the item ends on the line, you can use the grid-column-end and grid-row-end properties. You can also choose to use the grid-column or grid-row shorthand properties instead.Here is an example of using the grid-column property to make an element stretch across all columns.
.element {
grid-column: 1 / -1;
}
grid-template-areas: The property is used to provide a name for the items you are going to position on the grid.:::interactive_editor
<link rel="stylesheet" href="styles.css">
<div class="container">
<div class="header">Header</div>
<div class="sidebar">Sidebar</div>
<div class="main">Main Content</div>
<div class="footer">Footer</div>
</div>
.container {
display: grid;
grid-template-columns: 200px 1fr;
grid-template-rows: auto 1fr auto;
grid-template-areas:
"header header"
"sidebar main"
"footer footer";
gap: 20px;
}
.header {
grid-area: header;
background-color: #4CAF50;
padding: 10px;
color: white;
}
.sidebar {
grid-area: sidebar;
background-color: #f4f4f4;
padding: 10px;
}
.main {
grid-area: main;
background-color: #e0e0e0;
padding: 10px;
}
.footer {
grid-area: footer;
background-color: #4CAF50;
padding: 10px;
color: white;
}
:::
Review the CSS Grid topics and concepts.