OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script> |
| 3 if (window.internals) { |
| 4 internals.settings.setCSSStickyPositionEnabled(true); |
| 5 } |
| 6 </script> |
| 7 |
| 8 <style> |
| 9 body { |
| 10 margin: 0; |
| 11 height: 2000px; |
| 12 overflow: hidden; /* hide scrollbars */ |
| 13 } |
| 14 |
| 15 #spacer { |
| 16 height: 200px; |
| 17 } |
| 18 |
| 19 .container { |
| 20 background-color: red; |
| 21 width: 200px; |
| 22 height: 400px; |
| 23 outline: 2px solid black; |
| 24 } |
| 25 |
| 26 .box { |
| 27 width: 200px; |
| 28 height: 200px; |
| 29 } |
| 30 |
| 31 .sticky { |
| 32 position: sticky; |
| 33 top: 0px; |
| 34 background-color: green; |
| 35 } |
| 36 |
| 37 </style> |
| 38 <script> |
| 39 function doTest() |
| 40 { |
| 41 window.scrollTo(0, 200); |
| 42 // When the spacer's height is changed the sticky container moves up which s
hould now |
| 43 // require sliding the sticky box down. |
| 44 document.getElementById('spacer').style.height = '0px'; |
| 45 } |
| 46 window.addEventListener('load', doTest, false); |
| 47 </script> |
| 48 <div id="spacer"></div> |
| 49 <div class="container"> |
| 50 <div class="sticky box"></div> |
| 51 </div> |
OLD | NEW |