Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <title>position:sticky elements should respect the top constraint when nested</t itle> | |
| 3 <link rel="match" href="position-sticky-nested-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 nested position:sticky elemen ts 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 width: 100px; | |
| 17 height: 250px; | |
| 18 overflow: auto; | |
| 19 } | |
| 20 | |
| 21 .contents { | |
| 22 height: 1000px; | |
| 23 } | |
| 24 | |
| 25 .padding { | |
| 26 height: 200px; | |
| 27 } | |
| 28 | |
| 29 .outerSticky { | |
| 30 background-color: green; | |
| 31 position: sticky; | |
|
flackr
2017/03/17 17:42:01
For compatibility with Safari, I feel like we shou
smcgruer
2017/03/17 17:59:30
Asked on #testing, gsnedders said we shouldn't.
flackr
2017/03/17 18:25:34
Acknowledged.
| |
| 32 width: 100px; | |
| 33 height: 100px; | |
| 34 } | |
| 35 | |
| 36 .indicator { | |
|
flackr
2017/03/17 17:42:01
Should we also have an outer indicator for the out
smcgruer
2017/03/17 17:59:30
Done.
| |
| 37 background-color: red; | |
| 38 position: absolute; | |
| 39 left: 0; | |
| 40 width: 100px; | |
| 41 height: 50px; | |
| 42 } | |
| 43 | |
| 44 .innerSticky { | |
| 45 background-color: fuchsia; | |
| 46 position: sticky; | |
| 47 width: 100px; | |
| 48 height: 50px; | |
| 49 } | |
| 50 </style> | |
| 51 | |
| 52 <script> | |
| 53 window.addEventListener('load', function() { | |
| 54 for (const scroller of document.querySelectorAll('.scroller')) { | |
| 55 scroller.scrollTop = 250; | |
| 56 } | |
| 57 }); | |
| 58 </script> | |
| 59 | |
| 60 <div class="group"> | |
| 61 <div class="scroller"> | |
| 62 <div class="contents"> | |
| 63 <div class="padding"></div> | |
| 64 <div class="outerSticky" style="top: 0;"> | |
| 65 <div class="indicator" style="top: 0;"></div> | |
| 66 <div class="innerSticky" style="top: 0;"></div> | |
| 67 </div> | |
| 68 </div> | |
| 69 </div> | |
| 70 </div> | |
| 71 | |
| 72 <div class="group"> | |
| 73 <div class="scroller"> | |
| 74 <div class="contents"> | |
| 75 <div class="padding"></div> | |
| 76 <div class="outerSticky" style="top: 75px;"> | |
| 77 <div class="indicator" style="top: 25px;"></div> | |
| 78 <div class="innerSticky" style="top: 100px;"></div> | |
| 79 </div> | |
| 80 </div> | |
| 81 </div> | |
| 82 </div> | |
| 83 | |
| 84 <div class="group"> | |
| 85 <div class="scroller"> | |
| 86 <div class="contents"> | |
| 87 <div class="padding"></div> | |
| 88 <div class="outerSticky" style="top: 125px;"> | |
| 89 <div class="indicator" style="top: 50px;"></div> | |
| 90 <div class="innerSticky" style="top: 250px;"></div> | |
| 91 </div> | |
| 92 </div> | |
| 93 </div> | |
| 94 </div> | |
| 95 | |
| 96 <div>You should see three green and fuchsia boxes above. No red should be visibl e.</div> | |
| OLD | NEW |