Home >Web Front-end >CSS Tutorial >How Can I Prevent Scrollbar-Induced Layout Shifts in Web Design?
Preventing Scrollbar Displacement
In some web designs, center-aligned DIVs may be used. However, when transitioning between pages that require scrolling and those that do not, the addition of a scrollbar can cause the page layout to shift slightly. This can be an inconvenience for users.
To prevent this issue without manually displaying the scrollbar on every page, you can modify the CSS styles:
CSS:
html { overflow-y: scroll; }
Explanation:
Note:
The above is the detailed content of How Can I Prevent Scrollbar-Induced Layout Shifts in Web Design?. For more information, please follow other related articles on the PHP Chinese website!