grid-item-margin-right-auto-003.html (3770B)
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: margin-right:auto + align-self</title> 9 <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1176793"> 10 <link rel="help" href="https://drafts.csswg.org/css-grid/#auto-margins"> 11 <link rel="match" href="grid-item-margin-right-auto-003-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: 1px solid; 23 border-block-start: 2px solid blue; 24 grid-template: 1px 32px 3px / 3px 20px 2px; 25 margin-right: 4px; 26 } 27 28 span { 29 grid-area: 2 / 2; /* the center 32 x 20 pixel area */ 30 display: block; 31 width: 13px; 32 height: 9px; 33 background: grey; 34 border-block-start: 2px solid blue; 35 border-inline-start: 2px solid lime; 36 margin: 1px 1px 2px 2px; 37 margin-right: auto; 38 justify-self: start; 39 } 40 41 abs1,abs2,abs3,abs4 { 42 position: absolute; 43 top:0;left:0;bottom:0;right:0; 44 background: lightgrey; 45 } 46 abs1 { grid-area: 1 / 1 / 2 / 4; } 47 abs2 { grid-area: 1 / 1 / 4 / 2; } 48 abs3 { grid-area: 1 / 3 / 4 / 4; } 49 abs4 { grid-area: 3 / 1 / 4 / 4; } 50 51 .hl { writing-mode: horizontal-tb; direction:ltr; } 52 .hr { writing-mode: horizontal-tb; direction:rtl; } 53 .vl { writing-mode: vertical-lr; } 54 .vr { writing-mode: vertical-rl; } 55 .vlr { writing-mode: vertical-lr; direction:rtl; } 56 .vrl { writing-mode: vertical-rl; direction:ltr; } 57 58 .hl { -webkit-writing-mode: horizontal-tb; direction:ltr; } 59 .hr { -webkit-writing-mode: horizontal-tb; direction:rtl; } 60 .vl { -webkit-writing-mode: vertical-lr; } 61 .vr { -webkit-writing-mode: vertical-rl; } 62 .vlr { -webkit-writing-mode: vertical-lr; direction:rtl; } 63 .vrl { -webkit-writing-mode: vertical-rl; direction:ltr; } 64 65 .astart { align-self:start; } 66 .aend { align-self:end; } 67 .aflexstart { align-self:flex-start; } 68 .aflexend { align-self:flex-end; } 69 .aselfstart { align-self:self-start; } 70 .aselfend { align-self:self-end; } 71 .acenter { align-self:center; } 72 .aleft { align-self:left; } 73 .aright { align-self:right; } 74 .astretch1 { align-self:stretch; } 75 .astretch2 { align-self:stretch; width:13px; height:auto; } 76 .astretch3 { align-self:stretch; height:auto; } 77 .astretch4 { align-self:stretch; width:auto; } 78 .astretch5 { align-self:stretch; width:auto; max-width:13px; } 79 .astretch6 { align-self:stretch; height:auto; max-height:9px; } 80 .astretch7 { align-self:stretch; width:auto; height:auto; max-width:13px; max-height:9px; } 81 .aauto { align-self:auto; } 82 83 </style> 84 </head> 85 <body> 86 87 <script> 88 var gridwm = [ "hl", "hr", "vl" ]; // *-004.html tests vr/vlr/vrl 89 var wm = [ "hl", "hr", "vl", "vr", "vlr", "vrl" ]; 90 var test = [ "start", "end", "flexstart", "flexend", "center", "left", "right", 91 "stretch1", "stretch2", "stretch3", "stretch4", "stretch5", 92 "stretch6", "stretch7", "auto" ]; 93 for (var i = 0; i < gridwm.length; ++i) { 94 for (var j = 0; j < wm.length; ++j) { 95 for (var k = 0; k < test.length; ++k) { 96 var div = document.createElement("div"); 97 div.className = "grid " + gridwm[i]; 98 var span = document.createElement("span"); 99 span.className = wm[j] + " a" + test[k]; 100 div.appendChild(span); 101 div.appendChild(document.createElement("abs1")); 102 div.appendChild(document.createElement("abs2")); 103 div.appendChild(document.createElement("abs3")); 104 div.appendChild(document.createElement("abs4")); 105 106 document.body.appendChild(div) 107 } 108 document.body.appendChild(document.createElement("separator")); 109 } 110 } 111 </script> 112 113 114 </body> 115 </html>