background attachment
时间: 2023-10-12 13:05:06 浏览: 114
background-attachment 的学习.zip
"background-attachment" is a CSS property that specifies whether the background image of an element should scroll with the rest of the content or remain fixed in place as the content is scrolled. There are two possible values for this property:
1. "scroll": This is the default value, and it means that the background image will scroll along with the content as the user scrolls the page.
2. "fixed": This value means that the background image will remain fixed in place as the user scrolls the page, creating a parallax effect.
Here's an example of how to use the "background-attachment" property in CSS:
```
body {
background-image: url('background.jpg');
background-attachment: fixed;
}
```
This code sets the background image of the body element to "background.jpg" and sets the "background-attachment" property to "fixed", which means that the background image will remain fixed in place as the user scrolls the page.
阅读全文