position-sticky-flexbox.html (2047B)
1 <!DOCTYPE html> 2 <title>position:sticky elements should work correctly with flexbox</title> 3 <link rel="match" href="position-sticky-flexbox-ref.html" /> 4 <link rel="help" href="https://www.w3.org/TR/css-position-3/#sticky-pos" /> 5 <meta name="assert" content="This test checks that position:sticky elements interoperate correctly with flexbox" /> 6 7 <script src="../resources/ref-rectangle.js"></script> 8 9 <style> 10 .scroller { 11 overflow: scroll; 12 width: 350px; 13 height: 100px; 14 margin-bottom: 15px; 15 } 16 17 .flex-container { 18 width: 600px; 19 position: relative; 20 display: flex; 21 flex-flow: row wrap; 22 } 23 24 .sticky { 25 position: sticky; 26 left: 50px; 27 } 28 29 .green { 30 background-color: green; 31 } 32 33 .flex-item { 34 width: 100px; 35 height: 85px; 36 display: flex; 37 } 38 39 .indicator { 40 position: absolute; 41 background-color: red; 42 width: 100px; 43 height: 85px; 44 } 45 </style> 46 47 <script> 48 window.addEventListener('load', function() { 49 document.getElementById('scroller1').scrollLeft = 50; 50 document.getElementById('scroller2').scrollLeft = 150; 51 document.getElementById('scroller3').scrollLeft = 250; 52 createIndicatorForStickyElements(document.querySelectorAll('.sticky')); 53 }); 54 </script> 55 56 <p>You should see three green boxes of varying size below. There should be no red or blue.</p> 57 58 <div id="scroller1" class="scroller"> 59 <div class="flex-container"> 60 <div class="indicator" style="left: 100px;"></div> 61 <div class="flex-item"></div> 62 <div class="sticky green flex-item"></div> 63 <div class="green flex-item"></div> 64 </div> 65 </div> 66 67 <div id="scroller2" class="scroller"> 68 <div class="flex-container"> 69 <div class="indicator" style="left: 200px;"></div> 70 <div class="flex-item"></div> 71 <div class="sticky green flex-item"></div> 72 <div class="green flex-item"></div> 73 </div> 74 </div> 75 76 <div id="scroller3" class="scroller"> 77 <div class="flex-container"> 78 <div class="indicator" style="left: 300px;"></div> 79 <div class="flex-item"></div> 80 <div class="sticky green flex-item"></div> 81 <div class="green flex-item"></div> 82 </div> 83 </div>