CSS 背景附件
CSS background-attachment
The background-attachment
property specifies whether the background image should scroll or be fixed (will not scroll with the rest of the page):
例子
Specify that the background image should be fixed:
body {
background-image: url("img_tree.png");
background-repeat: no-repeat;
background-position: right top;
background-attachment: fixed;
}
亲自尝试 »
例子
Specify that the background image should scroll with the rest of the page:
body {
background-image: url("img_tree.png");
background-repeat: no-repeat;
background-position: right top;
background-attachment: scroll;
}
亲自尝试 »
The CSS Background Attachment Property
Property | Description |
---|---|
background-attachment | Set whether a background image is fixed or scrolls with the rest of the page |
CSS — Background Attachment — W3Schools Video
This video is an introduction to 背景附件 in CSS.
Part of a series of video tutorials to learn CSS for beginners!