Skip to content

Instantly share code, notes, and snippets.

@oczki
Created August 16, 2020 14:24
Show Gist options
  • Save oczki/1136d9f89a502afac1593eeed8fe0561 to your computer and use it in GitHub Desktop.
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.
/* 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