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