Answer the question
In order to leave comments, you need to log in
How to remove the page shift to the left when the scrollbar appears?
Good day to all.
When dynamically updating the tab, the height changes, which causes scrolling (vertical) in the browser, and the page shifts slightly to the left by the width of the scroll. how to make it so that scrolling does not affect the markup?
Thank you.
Answer the question
In order to leave comments, you need to log in
With the help calc(100vw - 100%)
, you can calculate the width of the scrollbar (and if it is not displayed, it will be 0). Idea: With a negative margin-right increase the width of the <html> by that width. At the same time, a horizontal scroll bar appears - hide it.
html {
overflow-x: hidden;
margin-right: calc(-1 * (100vw - 100%));
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question