perspective-containing-block-dynamic-1a.html (1401B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>CSS transforms: Creating containing block for fixed positioned elements</title> 4 <link rel="author" title="L. David Baron" href="https://dbaron.org/"> 5 <link rel="author" title="Mozilla" href="http://www.mozilla.org/"> 6 <link rel="help" href="https://drafts.csswg.org/css-transforms-2/#perspective-property"> 7 <link rel="match" href="containing-block-dynamic-1-ref.html"> 8 <meta name="assert" content="It also establishes a containing block (somewhat similar to position: relative), just like the transform property does."> 9 <meta name="flags" content="dom"> 10 <style> 11 html, body { margin: 0; padding: 0 } 12 #changeperspective { 13 position: absolute; 14 top: 100px; 15 left: 100px; 16 } 17 18 #abscovered { 19 position: absolute; 20 top: 50px; 21 left: 50px; 22 background: red; 23 height: 100px; 24 width: 100px; 25 } 26 27 #fixedmoves { 28 position: fixed; 29 top: 150px; 30 left: 150px; 31 background: green; 32 height: 100px; 33 width: 100px; 34 } 35 </style> 36 <body> 37 <div id="changeperspective" style="perspective: 1000px"> 38 <div id="abscovered"></div> 39 <div id="fixedmoves"></div> 40 </div> 41 <script> 42 var changeperspective = document.getElementById("changeperspective"); 43 var fixedmoves = document.getElementById("fixedmoves"); 44 var causeFlush = fixedmoves.offsetTop; 45 changeperspective.style.perspective = ""; 46 </script> 47 </body>