scrollable-box-with-nested-stacking-context.html 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <link rel="match" href="reference/scrollable-box-with-nested-stacking-context-ref.html" />
  2. <style>
  3. * {
  4. scrollbar-width: none;
  5. }
  6. #scrollable-box {
  7. width: 300px;
  8. height: 500px;
  9. overflow: auto;
  10. position: relative;
  11. border: 2px solid black;
  12. }
  13. .content {
  14. height: 1000px;
  15. background-color: lightblue;
  16. }
  17. .abspos {
  18. position: absolute;
  19. bottom: 0px;
  20. right: 0px;
  21. width: 150px;
  22. height: 50px;
  23. background-color: coral;
  24. z-index: 1000;
  25. display: flex;
  26. }
  27. .box {
  28. background-color: magenta;
  29. width: 100px;
  30. height: 100px;
  31. position: relative;
  32. top: 0px;
  33. left: 0px;
  34. }
  35. </style>
  36. <div id="scrollable-box">
  37. <div class="content">
  38. Lots of scrollable content here!
  39. <div class="box">box</div>
  40. </div>
  41. <div class="abspos"><div class="box">box</div></div>
  42. </div>
  43. <script>
  44. const scrollContainer = document.getElementById("scrollable-box");
  45. scrollContainer.scrollTop = 500;
  46. </script>