grid-auto-margin-and-replaced-item-001.html (1385B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>CSS Grid Layout Test: Margin auto and replaced grid item</title> 4 <link rel="author" title="Hyunjune Kim" href="mailto:hyunjune.kim@samsung.com"> 5 <link rel="help" href="https://www.w3.org/TR/css-grid-1/#alignment"> 6 <meta name="assert" content="Checks width of the nested grid container applied 'margin:auto' with a replaced item which has a property called max-height."> 7 <link rel="match" href="grid-auto-margin-and-replaced-item-001-ref.html"> 8 <style> 9 #reference-overlapped-red { 10 position: absolute; 11 background-color: red; 12 width: 100px; 13 height: 100px; 14 left:0; 15 right:0; 16 margin: auto; 17 z-index: -1; 18 } 19 .grid { 20 display: grid; 21 } 22 .nested-grid { 23 display: grid; 24 margin: auto; 25 } 26 img { 27 max-height: 100%; 28 } 29 </style> 30 31 <body onload="loadImage()"> 32 33 <p>Test passes if there is a filled green square and <strong>no red</strong>.</p> 34 35 <div class="grid"> 36 <div id="reference-overlapped-red"></div> 37 <div class="nested-grid"> 38 <img id="replaced"> 39 </div> 40 </div> 41 42 <script> 43 function loadImage() { 44 // Use svg for a 100x100 green square so we don't have to wait for replaced.onload. 45 replaced.src = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' width='100' height='100'%3E%3Crect width='100%25' height='100%25' fill='green'/%3E%3C/svg%3E"; 46 } 47 </script>