grid-abspos-items-014.html (2376B)
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: abs pos static position (grid container as abs.pos. CB)</title> 9 <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1151243"> 10 <link rel="help" href="http://dev.w3.org/csswg/css-grid/#static-position"> 11 <link rel="match" href="grid-abspos-items-014-ref.html"> 12 <style type="text/css"> 13 html,body { 14 color:black; background-color:white; font-size:16px; padding:0; margin:0; 15 } 16 separator { clear:both; display:block; height:6px; } 17 18 .grid { 19 display: grid; 20 float: left; 21 position: relative; 22 border-style: solid; 23 border-width: 1px 3px 5px 7px; 24 border-block-start-color: blue; 25 border-inline-start-color: lime; 26 grid-template: 3px 51px 5px / 5px 33px 7px; 27 margin-right: 4px; 28 } 29 30 abs1,abs2,abs3,abs4 { 31 grid-area: 2 / 2 / 3 / 3; 32 position: absolute; 33 } 34 abs1 { top:17px; bottom:2px; background:lime; } 35 abs2 { right:13px; left:3px; background:pink; } 36 abs3 { right:5px; left:11px; top:9px; background:cyan; } 37 abs4 { top:23px; bottom:1px; left:11px; background:yellow; } 38 abs1::before { content:"1";} 39 abs2::before { content:"2";} 40 abs3::before { content:"3";} 41 abs4::before { content:"4";} 42 43 x { 44 grid-area: 2 / 2 / 3 / 3; 45 background: grey; 46 } 47 48 .hl { writing-mode: horizontal-tb; direction:ltr; } 49 .hr { writing-mode: horizontal-tb; direction:rtl; } 50 .vl { writing-mode: vertical-lr; } 51 .vr { writing-mode: vertical-rl; } 52 .vlr { writing-mode: vertical-lr; direction:rtl; } 53 .vrl { writing-mode: vertical-rl; direction:ltr; } 54 55 </style> 56 </head> 57 <body> 58 59 <script> 60 document.body.style.display="none"; 61 var wm = [ "hl", "hr", "vl", "vr", "vlr", "vrl" ]; 62 for (var i = 0; i < wm.length; ++i) { 63 for (var j = 0; j < wm.length; ++j) { 64 var div = document.createElement("div"); 65 div.className = "grid " + wm[i]; 66 div.appendChild(document.createElement("abs1")); 67 div.appendChild(document.createElement("abs2")); 68 div.appendChild(document.createElement("abs3")); 69 div.appendChild(document.createElement("abs4")); 70 div.appendChild(document.createElement("x")); 71 document.body.appendChild(div) 72 } 73 document.body.appendChild(document.createElement("separator")); 74 } 75 document.body.style.display=""; 76 </script> 77 78 79 </body> 80 </html>