4

#2 CSS PROPERTY - BACKGROUND ATTACHMENT

 3 years ago
source link: https://dev.to/pawanbhayde/2-css-property-background-attachment-pic
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

#2 CSS PROPERTY - BACKGROUND ATTACHMENT

Apr 21 Originally published at dev.to

・1 min read

A To Z CSS Tutorial (2 Part Series)

Value: scroll | fixed

Initial: scroll

Applies to: all elements

Inherited: no

Percentage values: N/A

If a background image is specified, the CSS property "background-attachment" determines if the image is in a fixed position in relation to the screen or if it scrolls with the content.

Example:

body{
background-color: red;
background-image: url(image.gif);
background-repeat: repeat-y;
background-attachment: fixed;
}
Enter fullscreen modeExit fullscreen mode

CSS1 core: UAs may treat "fixed" as "scroll". However, it is recommended they interpret "fixed" correctly, at least on the "HTML" and "BODY" elements, since there is no way for an author to provide an image only for those browsers that support "fixed".


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK