| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>position:sticky elements should respect the top constraint</title> |
| 3 <link rel="match" href="position-sticky-top-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 obey
their top anchor after scrolling" /> |
| 6 |
| 7 <style> |
| 8 .group { |
| 9 display: inline-block; |
| 10 position: relative; |
| 11 width: 150px; |
| 12 height: 300px; |
| 13 } |
| 14 |
| 15 .scroller { |
| 16 position: relative; |
| 17 width: 100px; |
| 18 height: 250px; |
| 19 overflow: auto; |
| 20 } |
| 21 |
| 22 .contents { |
| 23 height: 1000px; |
| 24 } |
| 25 |
| 26 .padding { |
| 27 height: 200px; |
| 28 } |
| 29 |
| 30 .box { |
| 31 width: 100px; |
| 32 height: 100px; |
| 33 } |
| 34 |
| 35 .indicator { |
| 36 background-color: red; |
| 37 position: absolute; |
| 38 left: 0; |
| 39 } |
| 40 |
| 41 .sticky { |
| 42 background-color: green; |
| 43 position: sticky; |
| 44 } |
| 45 </style> |
| 46 |
| 47 <script> |
| 48 window.addEventListener('load', function() { |
| 49 for (const scroller of document.querySelectorAll('.scroller')) { |
| 50 scroller.scrollTop = 250; |
| 51 } |
| 52 }); |
| 53 </script> |
| 54 |
| 55 <div class="group"> |
| 56 <div class="scroller"> |
| 57 <div class="indicator box" style="top: 250px;"></div> |
| 58 <div class="contents"> |
| 59 <div class="padding"></div> |
| 60 <div class="sticky box" style="top: 0;"></div> |
| 61 </div> |
| 62 </div> |
| 63 </div> |
| 64 |
| 65 <div class="group"> |
| 66 <div class="scroller"> |
| 67 <div class="indicator box" style="top: 325px;"></div> |
| 68 <div class="contents"> |
| 69 <div class="padding"></div> |
| 70 <div class="sticky box" style="top: 75px;"></div> |
| 71 </div> |
| 72 </div> |
| 73 </div> |
| 74 |
| 75 <div class="group"> |
| 76 <div class="scroller"> |
| 77 <div class="indicator box" style="top: 375px;"></div> |
| 78 <div class="contents"> |
| 79 <div class="padding"></div> |
| 80 <div class="sticky box" style="top: 125px;"></div> |
| 81 </div> |
| 82 </div> |
| 83 </div> |
| 84 |
| 85 <div>You should see three green boxes above. No red should be visible.</div> |
| OLD | NEW |