absolute-positioning-changing-containing-block-001.html (1657B)
1 <!DOCTYPE html> 2 <html lang=en class="reftest-wait"> 3 <meta charset="utf-8"> 4 <title>CSS Grid Layout Test: Absolute positioning changing containing block</title> 5 <link rel="author" title="Manuel Rego Casasnovas" href="mailto:rego@igalia.com"> 6 <link rel="help" href="https://drafts.csswg.org/css-grid-1/#abspos" title="9. Absolute Positioning"> 7 <link rel="match" href="absolute-positioning-changing-containing-block-001-ref.html"> 8 <meta name="assert" content="This test checks that absolutelly positioned children of a grid are properly sized when the containing block switches between the grid container and a grid ancestor."> 9 <style> 10 .wrapper { 11 width: 100px; 12 height: 100px; 13 margin-bottom: 25px; 14 background: purple; 15 position: relative; 16 } 17 18 .grid { 19 display: grid; 20 grid-template: 10px / 10px; 21 width: 50px; 22 height: 50px; 23 background: lightblue; 24 } 25 26 .item { 27 width: 75%; 28 height: 75%; 29 background: orange; 30 position: absolute; 31 } 32 </style> 33 34 <p>The test PASS if you see an orange box inside a purple box on top and a small orange box inside a light blue box inside a purple box on bottom.</p> 35 36 <div class="wrapper"> 37 <div id="grid-as-cb" class="grid" style="position: relative;"> 38 <div class="item"></div> 39 </div> 40 </div> 41 <div class="wrapper"> 42 <div id="grid-as-parent" class="grid"> 43 <div class="item"></div> 44 </div> 45 </div> 46 47 <script> 48 window.requestAnimationFrame(() => { 49 document.getElementById("grid-as-cb").style.position = "initial"; 50 document.getElementById("grid-as-parent").style.position = "relative"; 51 document.body.offsetLeft; 52 document.documentElement.classList.remove('reftest-wait'); 53 }); 54 </script> 55 56 </html>