Created
August 16, 2020 14:24
-
-
Save oczki/1136d9f89a502afac1593eeed8fe0561 to your computer and use it in GitHub Desktop.
CSS - Prevent that tiny horizontal shift of a webpage's centered body when its scrollbar appears.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* If body is centered, this will prevent the contents from shifting if a scrollbar appears. */ | |
@media screen and (min-width: 60em) { | |
html { | |
margin-left: calc(100vw - 100%); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment