Performance: Grid container
Grid container affects the browser's layout and paint phases by defining a grid-based layout, impacting how quickly the page content is arranged and displayed.
Jump into concepts and practice - no test required
display: grid; grid-template-columns: repeat(3, 1fr);
display: block; float: left; width: 33.33%;
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Float-based layout | Multiple DOM nodes with float styles | Multiple reflows due to float clearing | Higher paint cost due to layout thrashing | [X] Bad |
| Grid container layout | Same DOM nodes with grid container | Single reflow for layout calculation | Lower paint cost with efficient layout | [OK] Good |
display: grid; set.display: flex; creates a flexbox, not grid. position: grid; is invalid. grid-template-columns defines columns but does not make container a grid.grid-template-columns defines columns. Using 1fr 1fr 1fr creates 3 equal columns.3px is a fixed small width, not equal columns. grid-columns is invalid property. grid-template-rows sets rows, not columns. .container {
display: grid;
grid-template-columns: 100px 200px;
grid-template-rows: 50px 50px;
}
How many grid cells are created inside .container? .grid {
display: grid;
grid-template-columns: repeat(3);
}repeat() function needs two arguments: number of times and size, e.g. repeat(3, 1fr).repeat(3) is given, missing the size argument, so it's invalid.1fr which means flexible fraction.auto which sizes based on content, not remaining space. Options B and D put 150px in wrong column order.