This time I bring to you, what are the precautions, the following is a practical case, let's take a look.
1. background-attachmentAttribute
In CSS, use the background attachment attribute background-attachment to set the background imageWhether it scrolls with the object or remains fixed.
Syntax:
background-attachment:scroll/fixed;
Description:
The background-attachment attribute has only 2 attribute values. scroll means that the background image scrolls as the object scrolls, which is the default option; fixed means that the background image is fixed on the page, and only other content scrolls with the scroll bar.
Example:
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <style type="text/css"> #p1 { width:160px; height:1200px; border:1px solid gray; background-image:url("cartoongirl.gif"); background-repeat:no-repeat; background-attachment:fixed; } </style> </head> <body> <p id="p1"></p> </body> </html>
The preview effect in the browser is as follows:
I believe you have mastered the method after reading the case in this article, more Please pay attention to other related articles on the php Chinese website!
Recommended reading:
There are several ways to implement three-column layout in CSS
CSS and Sass development specifications
CSS to make the icon rotate when the mouse moves up
The above is the detailed content of Detailed explanation of the use of CSS background-attachment. For more information, please follow other related articles on the PHP Chinese website!