opt-out-table.html (1137B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <link rel="help" href="https://drafts.csswg.org/css-scroll-anchoring-1/"> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <style> 7 8 #scroller { 9 height: 200px; 10 overflow: scroll; 11 } 12 #before { height: 50px; } 13 #table { 14 display: table; 15 overflow-anchor: none; 16 width: 100px; 17 height: 100px; 18 margin-bottom: 500px; 19 } 20 21 </style> 22 <div id="scroller"> 23 <div id="before"></div> 24 <div id="table">content</div> 25 </div> 26 <script> 27 28 // Tests that the anchor exclusion API works with tables 29 30 test(() => { 31 let scroller = document.querySelector('#scroller'); 32 let before = document.querySelector('#before'); 33 34 // Scroll down so that #table is the only element in view 35 scroller.scrollTop = 50; 36 37 // Expand #before so that we might perform a scroll adjustment 38 before.style.height = "100px"; 39 40 // We shouldn't have selected #table as an anchor as it is 41 // 'overflow-anchor: none' 42 assert_equals(scroller.scrollTop, 50); 43 }, "A table with 'overflow-anchor: none' shouldn't generate any scroll anchor candidates."); 44 45 </script>