Skip to content

Instantly share code, notes, and snippets.

@anwas
Last active October 10, 2019 06:27
Show Gist options
  • Save anwas/5aa3d0b9e6a750264e2b620198eec970 to your computer and use it in GitHub Desktop.
Save anwas/5aa3d0b9e6a750264e2b620198eec970 to your computer and use it in GitHub Desktop.
[Full screen vertically scrolling parallax] #css #parallax #scrolling
<!-- https://www.w3schools.com/howto/howto_css_parallax.asp -->
<style>
body, html {
min-height: 100vh;
}
.parallax {
/* The image used */
background-image: url("img_parallax.jpg");
/* Full height */
height: 100%;
/* Create the parallax scrolling effect */
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
/* Turn off parallax scrolling for tablets and phones. Increase/decrease the pixels if needed */
@media only screen and (max-device-width: 1024px) {
.parallax {
background-attachment: scroll;
}
}
</style>
<!-- Container element -->
<div class="parallax"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment