scrollIntoView-inline-image.html (758B)
1 <!doctype html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <title>scrollIntoView uses the element's bounding rect rather than line box</title> 5 <link rel="help" href="https://drafts.csswg.org/cssom-view/#scroll-an-element-into-view"> 6 <style> 7 img { 8 height: 100vh; 9 width: 100px; 10 } 11 body { 12 margin-bottom: 100vh; 13 } 14 </style> 15 <body> 16 <a id="scrollto">To be scrolled into view</a><img src="/images/blue.png"> 17 </body> 18 <script> 19 20 test(t => { 21 window.scrollTo(0, 0); 22 const target = document.getElementById("scrollto"); 23 target.scrollIntoView(); 24 assert_approx_equals(window.scrollY, target.offsetTop, 1); 25 }, "Scrolling an inline element with a large line height uses the bounding rect"); 26 </script>