天天看点

CSS中背景图片滚动属性background-attachment

   该属性用来定义背景图片是否随浏览器滑块的拖动而滚动,在背景图片滚动属性中,可以使用两个属性值,分别为scroll和fixed,

     background-attachment: scroll | fixed;

     *scroll:   背景图片随滑块的变化而滚动。

     *fixed: 背景图片固定不动。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <title> New Document </title>
  <meta name="Generator" content="EditPlus">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <style>
    div {
    background-position: center;
    background-repeat: no-repeat;
    background-image: url(images/round.jpg);
    width: 400px;
    height: 100px;
    background-attachment: scroll;
  }
  </style>
 </head>
 <body>
    <div>这是背景图片滚动属性的实例</div>
 </body>
</html>