当前位置: 首页 > 文档资料 > CSS 入门教程 >

background-attachment

优质
小牛编辑
125浏览
2023-12-01

描述 (Description)

background-attachment确定平铺上下文和背景图像的滚动状态。

可能的值 (Possible Values)

  • scroll - 设置为滚动的背景图像将与文档的其余部分一起滚动。

  • fixed - 设置为固定的背景图像将保持锁定到位,同时文档的其余部分滚动。

适用于 (Applies to)

所有HTML元素。

DOM语法 (DOM Syntax)

object.style.backgroundAttachment = scroll | fixed;

例子 (Example)

<html>
   <head>
   </head>
   <body>
      <p <b>style = "background-image:url(/images/logo.png);  
         background-attachment:scroll;
         background-attachment:scroll;
         background-repeat: no-repeat;
         background-attachment: fixed;"</b>>
         This parapgraph has scrolling background image.
         This parapgraph has fixed repeated background image.
         This parapgraph has fixed repeated background image.
         This parapgraph has fixed repeated background image. 
         This parapgraph has fixed repeated background image.
         This parapgraph has fixed repeated background image.
      </p>
   </body>
</html>