您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

CSS的background-attachment使用详解

2025/6/13 12:46:24发布24次查看
这次给大家带来,的注意事项有哪些,下面就是实战案例,一起来看一下。
一、background-attachment属性
在css中,使用背景附件属性background-attachment可以设置背景图像是随对象滚动还是固定不动。
语法:
background-attachment:scroll/fixed;
说明:
background-attachment 属性只有2个属性值。scroll表示背景图像随对象滚动而滚动,是默认选项;fixed表示背景图像固定在页面不动,只有其他的内容随滚动条滚动。
举例:
<!doctype html>  <html xmlns="http://www.w3.org/1999/xhtml"> <head>     <title></title>     <style type="text/css">         #p1         {             width:160px;             height:1200px;             border:1px solid gray;             background-image:url(cartoongirl.gif);             background-repeat:no-repeat;             background-attachment:fixed;         }     </style> </head> <body>     <p id="p1"></p> </body> </html>
在浏览器预览效果如下:
相信看了本文案例你已经掌握了方法,更多精彩请关注其它相关文章!
推荐阅读:
css有几种实现三栏布局的方法
css与sass开发规范
css做出鼠标上移图标旋转
以上就是css的background-attachment使用详解的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product