Parallax scrolling effect using CSS Last Updated : 11 Oct, 2024 Comments Improve Suggest changes Like Article Like Report Parallax scrolling effect using CSS creates an illusion of depth by making background elements move slower than foreground elements as the user scrolls. This effect adds a sense of three-dimensionality, enhancing visual appeal and interactivity on web pages for a more dynamic experience.Approach: Creating Parallax Scrolling Effect Set Background Images: Assign background images to .parallax1 and .parallax2 classes using background-image property for visual content.Parallax Effect Properties: Use background-attachment: fixed to make the background stay static while scrolling.Background Positioning: Utilize background-position: center, background-repeat: no-repeat, and background-size: cover for proper image display.Define Height: Set min-height: 500px for the parallax sections to ensure enough scrolling space.Syntaxbackground-attachment: scroll/fixed/local; background-position: value; background-repeat: repeat/repeat-x/repeat-y/no-repeat;background-size: auto/length/cover/contain/; Example of Parallax scrolling effect using CSSExample: In this example we creates a parallax scrolling effect by setting background images with background-attachment: fixed for .parallax1 and .parallax2, making the background stay static while the content scrolls. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content= "width=device-width, initial-scale=1.0" /> <title>Parallax Scrolling Effect</title> <style> /* CSS for parallax effect */ .parallax1 { background-image: url( "https://media.geeksforgeeks.org/wp-content/uploads/20240313115219/HTML-tutorial.jpg"); min-height: 500px; background-attachment: fixed; background-position: center; background-repeat: no-repeat; background-size: cover; } .parallax2 { background-image: url( "https://media.geeksforgeeks.org/wp-content/uploads/20240313115240/CSS-Tutorial-(1).webp"); min-height: 500px; background-attachment: fixed; background-position: center; background-repeat: no-repeat; background-size: cover; } </style> </head> <body> <div class="parallax1"></div> <div style="height: 300px"> <h4> HTML stands for HyperText Markup Language. It is the standard language used to create and design web pages on the internet. It was introduced by Tim Berners-Lee in 1991 at CERN as a simple markup language. Since then, it has evolved through versions from HTML 2.0 to HTML5 (the latest 2024 version) </h4> </div> <div class="parallax2"></div> </body> </html> OutputParallax scrolling effect Example OutputNote: This parallax effect does not always work with mobiles and tablets, so you need to turn off the effect using media queries. Comment More infoAdvertise with us Next Article Parallax scrolling effect using CSS A AyushSaxena Improve Article Tags : Misc Web Technologies HTML CSS Practice Tags : Misc Similar Reads How to create a smooth scrolling effect using CSS ? Smooth scrolling is employed on web pages to enhance the user experience by providing a visually appealing and seamless transition between different sections of the page. It improves readability and enhances navigation. Using the CSS property scroll-behaviour we can achieve the smooth scrolling effe 2 min read Create a Reverse Scrolling Effect using HTML and CSS Creating an attractive UI with a reverse scroll effect can be an engaging design. The Reverse Scrolling effect facilitates a unique and visually interactive experience for users, which breaks the conventional top-down scrolling system to which the user is accustomed. In this article, we'll create a 2 min read Shimmer Effect using CSS A Shimmer Effect is much in trend to produce an illusional glass effect on articles, texts, or images. This might seem a very extravagant property from only some CSS frameworks but the fun part is we can do it using CSS and its properties very easily. First of all, create a div container with an art 2 min read script.aculo.us ScrollTo Effect In this article, we will demonstrate the effect of ScrollTo by using JavaScript library called script.aculo.us having smooth transition from one to another. We can adjust the duration of the effect as well. Syntax: Effect.ScrollTo('element_id', { duration:'0.2', offset:-20 }); Note: To use this libr 4 min read How to Create Parallax Effect in Tailwind CSS ? A parallax website includes fixed images in the background that are kept in place and the user can scroll down the page to see different parts of the image. If you use the parallax effect on our page then it helps the user to interact with the page. PreviewCreating Parallax Effect in Tailwind CSS At 3 min read Like