Languages
[Edit]
EN

CSS - parallax scrolling

0 points
Created by:
elmer
646

In this article, we would like to show you how to create parallax scrolling effect using CSS.

Quick solution:

 

Practical example

Edit

In order to create parallax scrolling effect, we need to set background-image for our parallax element with additional background properties.

Explanation:

  • background-image: url('https://example.com/image.png') - sets image as web page background,
  • background-attachment: fixed - makes the background doesn't move with the element, even if an element has a scrolling mechanism,
  • background-size: cover - scales the image (preserving its ratio) to the smallest possible size to fill the container, leaving no empty space.
  • background-repeat: no-repeat - makes the background image doesn't repeat.

References

Edit
  1. background-image - CSS: Cascading Style Sheets | MDN
  2. background-attachment - CSS: Cascading Style Sheets | MDN
  3. background-size - CSS: Cascading Style Sheets | MDN
  4. background-repeat - CSS: Cascading Style Sheets | MDN

Alternative titles

  1. CSS - scrolling with fixed background image
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join