unreachable-snap-positions-004.html (1304B)
1 <!DOCTYPE html> 2 <meta name="viewport" content="width=device-width,initial-scale=1"> 3 <link rel="help" href="https://drafts.csswg.org/css-scroll-snap-1/#unreachable" /> 4 <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1905247"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <style> 8 .content { 9 overflow-y: scroll; 10 scroll-snap-type: y mandatory; 11 white-space: nowrap; 12 max-height: 800px; 13 border: 2px solid black; 14 /* padding-right so you can see the scrollbar: */ 15 padding-right: 10px; 16 writing-mode: vertical-lr; 17 } 18 .item { 19 height: 500px; 20 width: 200px; 21 border: 3px solid orange; 22 box-sizing: border-box; 23 scroll-snap-align: start; 24 display: inline-block; 25 writing-mode: horitontal-tb; 26 } 27 </style> 28 29 <div id="scroller" class="content"> 30 <!-- There's intentionally no whitespace between these tags, so that they're 31 laid out flush with each other with no space character between them. --> 32 <div class="item" style="height: 610px; background:teal"></div 33 ><div class="item" style="height: 200px; background:pink"></div> 34 </div> 35 36 <script> 37 test(() => { 38 scroller.scrollTop = 6; 39 assert_equals(scroller.scrollTop, 10); 40 }, "Snaps to the positions defined by the element as much as possible"); 41 </script>