0% completed
The background attachment property controls how a background image behaves when the page is scrolled. With this property, you can decide if the background image stays fixed or scrolls along with the rest of the page content. This helps create various visual effects in your design.
There are a few values for background attachment. The most common are fixed
(the background does not move when scrolling) and scroll
(the background moves with the content).
Follow below syntax to add background attachment in CSS code.
element { background-attachment: value; }
Explanation:
fixed
or scroll
(or other valid values) to get the desired effect.In this example, we will use a fixed background attachment so that the background image remains stationary while the rest of the page scrolls.
Explanation:
background-attachment: fixed;
ensures that the background image does not move while scrolling.In this example, we will use the default scroll behavior so that the background image moves along with the page content when scrolling.
Explanation:
background-attachment: scroll;
ensures the background image scrolls with the rest of the content.This lesson demonstrates how to control background attachment in your CSS. By understanding the difference between fixed
and scroll
, you can create interesting scrolling effects to enhance the visual design of your web pages.
.....
.....
.....