position-sticky-fractional-offset-ref.html (1069B)
1 <!DOCTYPE html> 2 <style> 3 .container { 4 width: 100px; 5 height: 100px; 6 overflow-y: scroll; 7 /** 8 * The scroll container background color can affect whether we use light 9 * or dark scrollbars. Use the same color as the test to ensure they match 10 **/ 11 background: red; 12 display: inline-block; 13 } 14 .container div { 15 background: lightgreen; 16 } 17 </style> 18 19 <div class="container"> 20 <div style="height: calc(300px + 50px + 10.10px);"></div> 21 </div> 22 23 <div class="container"> 24 <div style="height: calc(300px + 50px + 10.25px);"></div> 25 </div> 26 27 <div class="container"> 28 <div style="height: calc(300px + 50px + 10.50px);"></div> 29 </div> 30 31 <div class="container"> 32 <div style="height: calc(300px + 50px + 10.75px);"></div> 33 </div> 34 35 <div class="container"> 36 <div style="height: calc(300px + 50px + 10.90px);"></div> 37 </div> 38 39 <script> 40 window.onload = function() { 41 var containers = document.getElementsByClassName('container'); 42 for (let i = 0; i < containers.length; i++) { 43 containers[i].scrollTo(0, 20); 44 } 45 }; 46 </script> 47 </html>