CSS background-attachment属性

CSS background-attachment属性

描述

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

可能的值

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

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

适用于

所有HTML元素。

DOM语法

object.style.backgroundAttachment = scroll | fixed;

示例

<html>
   <head>
   </head>

   <body>
      <p style = "background-image:url(https://geek-docs.com/static/logo.png);  
         background-attachment:scroll;
         background-attachment:scroll;
         background-repeat: no-repeat;
         background-attachment: fixed;">

         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> 

它将产生以下结果 –

CSS backgroundAttachment属性

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程