position-sticky-rendering-ref.html (1977B)
1 <!DOCTYPE html> 2 <title>Reference for position:sticky elements should be rendered at their sticky offset</title> 3 4 <style> 5 .group { 6 display: inline-block; 7 position: relative; 8 width: 150px; 9 height: 250px; 10 } 11 12 .inlineGroup { 13 display: inline-block; 14 position: relative; 15 width: 250px; 16 height: 150px; 17 } 18 19 .scroller { 20 position: relative; 21 width: 100px; 22 height: 200px; 23 overflow-x: hidden; 24 overflow-y: auto; 25 } 26 27 .inlineGroup .scroller { 28 position: relative; 29 width: 200px; 30 height: 100px; 31 overflow-x: auto; 32 overflow-y: hidden; 33 } 34 35 .contents { 36 height: 500px; 37 } 38 39 .inlineGroup .contents { 40 height: 100%; 41 width: 500px; 42 } 43 44 .indicator { 45 background-color: green; 46 position: absolute; 47 } 48 49 .box { 50 width: 100%; 51 height: 100px; 52 } 53 54 .inlineGroup .box { 55 height: 100%; 56 width: 100px; 57 } 58 </style> 59 60 <script> 61 window.addEventListener('load', function() { 62 document.getElementById('scroller1').scrollTop = 125; 63 document.getElementById('scroller2').scrollTop = 50; 64 document.getElementById('scroller3').scrollLeft = 125; 65 document.getElementById('scroller4').scrollLeft = 75; 66 }); 67 </script> 68 69 <div>You should see four green squares below. No red or blue should be visible.</div> 70 71 <div class="group"> 72 <div id="scroller1" class="scroller"> 73 <div class="contents"> 74 <div class="indicator box" style="top: 175px;"></div> 75 </div> 76 </div> 77 </div> 78 79 <div class="group"> 80 <div id="scroller2" class="scroller"> 81 <div class="contents"> 82 <div class="indicator box" style="top: 125px;"></div> 83 </div> 84 </div> 85 </div> 86 87 <!-- Force break to make sure we are within 800px wide. --> 88 <div></div> 89 90 <div class="inlineGroup"> 91 <div id="scroller3" class="scroller"> 92 <div class="contents"> 93 <div class="indicator box" style="left: 175px;"></div> 94 </div> 95 </div> 96 </div> 97 98 <div class="inlineGroup"> 99 <div id="scroller4" class="scroller"> 100 <div class="contents"> 101 <div class="indicator box" style="left: 150px;"></div> 102 </div> 103 </div> 104 </div>