'background-attachment' Example : background attachment « CSS « HTML / CSS






'background-attachment' Example

  
    
<html>
<head>
</head>
<body>
<div style="background:blue url(http://www.java2s.com/style/logo.png) repeat top left; 
            width:200; 
            border:3; 
            height:150; font-size:14">
            <br><br><br><br><br><br><br><br><br>
            </div>
            <br><br><br><br><br><br><br><br><br>
<div style="background-color:red; 
            background-attachment:fixed; 
            background-image:url(http://www.java2s.com/style/logo.png); 
            background-repeat:repeat; 
            background-position-x:top; 
            background-position-y:left; 
            width:200; 
            border:3; 
            height:150; 
            font-size:14">
            background-attachment is fixed.
            </div>
</body>
</html>

    
      
        
    
  








Related examples in the same category

1.Use background-attachment:scroll to scroll a background image when the user scrolls the content. This is the default value.
2.Use background-attachment:fixed to prevent the image from scrolling.
3.background-attachment: fixed;background-position: center;
4.background-attachment: fixed;
5.Set background-attachment to fixed
6.background-attachment: scroll