目录

background-attachment

描述 (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 class="notranslate">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> 

它会产生以下结果 -

新页面打开
↑回到顶部↑
WIKI教程 @2018