Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the background-attachment attribute in CSS

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Editor to share with you how to use the background-attachment attribute in CSS, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

CSSbackground-attachment is an attribute of css software. Property sets whether the background image is fixed or scrolled as the rest of the page is scrolled, supported by all browsers.

Definition and usage of CSSbackground-attachment

The background-attachment property sets whether the background image is fixed or scrolled along with the rest of the page.

Default value:

Scroll

Inheritance:

No

Version:

CSS1

JavaScript syntax:

Object.style.backgroundAttachment= "fixed"

How to set a fixed background image:

Body {background-image:url (bgimage.gif); background-attachment:fixed;}

Browsers support editing

The background-attachment property is supported by all browsers.

Note: no version of InternetExplorer (including IE8) supports the attribute value "inherit".

Possible values of CSSbackground-attachment

Value

Description

Scroll

Default value. The background image moves as the rest of the page scrolls.

Fixed

The background image does not move when the rest of the page scrolls.

Inherit

A setting that specifies that the background-attachment attribute should be inherited from the parent element

TIY instance editing

How to set a fixed background image

This example shows how to set a fixed background image. The image does not scroll with the rest of the page.

Body

{

Background-image:url (/ i/eg_bg_02.gif)

Background-repeat:no-repeat

Background-attachment:fixed

}

one

The image does not scroll with the rest of the page.

The image does not scroll with the rest of the page.

The image does not scroll with the rest of the page.

The image does not scroll with the rest of the page.

The image does not scroll with the rest of the page.

The image does not scroll with the rest of the page.

The image does not scroll with the rest of the page.

The image does not scroll with the rest of the page.

The image does not scroll with the rest of the page.

The image does not scroll with the rest of the page.

The image does not scroll with the rest of the page.

The image does not scroll with the rest of the page.

The above is all the content of the article "how to use the background-attachment attribute in CSS". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report