⊗mkSpGdSg 121 of 128 menu

Subgrids in CSS

A subgrid is a variation of a nested grid, but unlike it, it affects the size of the parent grid container. To set a subgrid, you need to set the display property in the child element itself with a value of subgrid.

For example, let's create a nested grid in the fourth element:

<div id="parent"> <div id="elem1">1</div> <div id="elem2">2</div> <div id="elem3">3</div> <div id="elem4"> <div>5</div> <div>6</div> <div>7</div> <div>8</div> </div> </div> #parent { display: grid; grid-template: 1fr 1fr / 1fr 1fr; grid-gap: 5px; border: 2px solid #696989; padding: 10px; width: 600px; height: 200px; } #parent > div { padding: 10px; border: 1px solid #696989; } #elem4 { display: subgrid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; grid-gap: 5px; border: 2px solid #696989; padding: 5px; } #elem4 > div { grid-gap: 5px; padding: 6px; box-sizing: border-box; border: 1px solid #696989; }

:

Let's say you have a grid consisting of five elements arranged in two columns. Create a nested grid in the third element, which in turn will have two child elements.

Modify the previous task so that the nested grid has four children.

Create two nested grids - in the second element and the fifth element.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline