snapshot-containing-block-static-ref.html (714B)
1 <!DOCTYPE html> 2 <html> 3 <title>View transitions: use snapshot containing block for static position (ref)</title> 4 <link rel="help" href="https://drafts.csswg.org/css-view-transitions-1/"> 5 <link rel="author" href="mailto:bokan@chromium.org"> 6 7 <style> 8 body { 9 height: 400vh; 10 background-color: limegreen; 11 } 12 13 div { 14 position: absolute; 15 left: 200px; 16 top: 600px; 17 width: 100px; 18 height: 100px; 19 20 display: flex; 21 justify-content: center; 22 flex-direction: column; 23 align-items: center; 24 25 background: darkseagreen; 26 } 27 28 </style> 29 30 <div id="target">TARGET</div> 31 32 <script> 33 onload = () => { 34 const scrollTargetY = document.getElementById('target').offsetTop - 100; 35 window.scrollTo(0, scrollTargetY); 36 }; 37 </script>