grid-lanes-subgrid-002f-ref.html (1679B)
1 <!DOCTYPE HTML> 2 <!-- 3 Any copyright is dedicated to the Public Domain. 4 http://creativecommons.org/publicdomain/zero/1.0/ 5 --> 6 <html><head> 7 <meta charset="utf-8"> 8 <title>Reference: Grid Lanes layout with a subgrid (grid-lanes-subgrid-002f)</title> 9 <link rel="author" title="Mats Palmgren" href="mailto:mats@mozilla.com"> 10 <style> 11 html,body { 12 color:black; background-color:white; font:10px/1 monospace; padding:0; margin:0; 13 } 14 15 grid { 16 display: inline-grid; 17 grid-template-rows: 40px 30px 20px; 18 gap: 4px 2px; 19 padding: 1px 3px 5px 7px; 20 border: solid; 21 border-width: 3px 5px 1px 1px; 22 background: lightgrey content-box; 23 grid-auto-flow: column; 24 } 25 .rows { 26 grid-template-columns: 40px 30px 20px; 27 grid-auto-flow: row; 28 } 29 item { 30 background: grey; 31 width: 3ch; 32 position: relative; 33 } 34 item:nth-child(2n) { background:purple; width:auto; } 35 item:nth-child(1) { 36 border: solid; 37 border-width: 3px 5px 1px 1px; 38 margin: 7px 1px 5px 3px; 39 } 40 subgrid { 41 display: grid; 42 grid-row: auto/span 2; 43 grid-column: auto/span 2; 44 grid: subgrid / subgrid; 45 grid-gap: 6px 8px; 46 background: yellow; 47 } 48 subgrid.definite { 49 grid-row-start:2; 50 } 51 subgrid.extent { 52 grid-row: 1/span 3; 53 } 54 .rows > subgrid.definite { 55 grid-column-start:2; 56 grid-row-start:auto; 57 } 58 .rows > subgrid.extent { 59 grid-row: auto/span 2; 60 grid-column: 1/span 3; 61 } 62 </style> 63 </head> 64 <body> 65 66 <!-- auto-placed subgrid inhibits subgridding when parent is doing grid-lanes layout ... --> 67 68 <grid class="rows"> 69 <item>1</item> 70 <subgrid class="definite"> 71 <item>4a</item> 72 <item>4b</item> 73 <item>4c</item> 74 </subgrid> 75 <item>2</item> 76 <item>3</item> 77 <item>5</item> 78 </grid> 79 80 </body></html>