Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The scroll-margin-top property doesn't work when using a container with `overflow: hidden` [closed]

scroll-margin-top does not seem to work properly when the element with scroll-margin-top has overflow: hidden.

section {
  scroll-margin-top: 3rem; /* height of sticky nav at top of page */
  overflow: hidden;
}

Why does overflow: hidden interfere with scroll-margin-top? Is there any way to use both properties on the same element at the same time?

like image 477
skalta Avatar asked Sep 06 '25 03:09

skalta


1 Answers

My problem was that the elements to which I had assigned the scroll-margin-top were sometimes in a container with overflow: hidden. As soon as the element is at the top and thus the scroll-margin protrudes from this container, the scroll-margin is also cut off by the overflow: hidden.

like image 106
skalta Avatar answered Sep 07 '25 20:09

skalta