Skip to content

Instantly share code, notes, and snippets.

@thetwopct
Last active June 21, 2019 06:06
Show Gist options
  • Save thetwopct/3a3bf9edb3c0fc211c3bf924bf654d1b to your computer and use it in GitHub Desktop.
Save thetwopct/3a3bf9edb3c0fc211c3bf924bf654d1b to your computer and use it in GitHub Desktop.
CSS Full Cover Background Images
/* becuase I always forget */
/* becuase I always forget */
body {
background-image: url('https://via.placeholder.com/250x200/d9d9d9/000000');
background-position: center center;
background-repeat: no-repeat;
// background-attachment: fixed; // remove to be fixed
background-size: cover;
background-color: #464646;
}
body {
/* Location of the image */
background-image: url('https://via.placeholder.com/250x200/d9d9d9/000000');
/* Background image is centered vertically and horizontally at all times */
background-position: center center;
/* Background image doesn't tile */
background-repeat: no-repeat;
/* Background image is fixed in the viewport so that it doesn't move when
the content's height is greater than the image's height */
background-attachment: fixed;
/* This is what makes the background image rescale based
on the container's size */
background-size: cover;
/* Set a background color that will be displayed
while the background image is loading and for fallover */
background-color: #464646;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment