Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $YECBGYFECGEAFWHA as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2

Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $BBWFDDBHHYHDXXAB as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2
css背景固定样式background-attachment属性基础介绍_创想鸟

css背景固定样式background-attachment属性基础介绍

这篇文章主要为大家带来css背景固定样式background-attachment属性基础介绍,需要的朋友可以参考下

一、background-attachment属性

在CSS中,使用背景附件属性background-attachment可以设置背景图像是随对象滚动还是固定不动。

语法:

background-attachment:scroll/fixed;

说明:

background-attachment 属性只有2个属性值。scroll表示背景图像随对象滚动而滚动,是默认选项;fixed表示背景图像固定在页面不动,只有其他的内容随滚动条滚动。

举例:

                 #p1        {            width:160px;            height:1200px;            border:1px solid gray;            background-image:url("cartoongirl.gif");            background-repeat:no-repeat;            background-attachment:fixed;        }        

立即学习“前端免费学习笔记(深入)”;

在浏览器预览效果如下:

css背景固定样式background-attachment属性基础介绍

分析:

大家在浏览器中拖动右边的滚动条会发现,背景图片在页面固定不动。

在IE或者360中设置background-attachment之后不能设置background-position属性,不然图片没办法在浏览器显示。大家可以测试一下google浏览器、Firefox浏览器。

以上就是css背景固定样式background-attachment属性基础介绍的详细内容,更多请关注创想鸟其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/1607863.html

赞 (0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2025年12月23日 21:13:02
CSS3+Js实现响应式导航条方法
下一篇 2025年12月23日 21:13:13

相关推荐

发表回复

登录后才能评论
关注微信