anchor-scroll-fixedpos-004-ref.html (497B)
1 <!DOCTYPE html> 2 3 <style> 4 body { 5 margin: 0; 6 } 7 8 div { 9 width: 100px; 10 height: 100px; 11 } 12 13 #anchor { 14 margin-top: 105vh; 15 background: orange; 16 } 17 18 #anchored { 19 position: absolute; 20 top: calc(105vh - 100px); 21 left: 100px; 22 background: green; 23 24 transform: scale(2); 25 } 26 </style> 27 28 <body> 29 <div id="anchor"></div> 30 <div id="anchored"></div> 31 32 <script> 33 const anchor = document.getElementById("anchor"); 34 anchor.scrollIntoView(false); 35 </script> 36 </body>