css背景有哪些相关属性?下面本篇文章给大家带来关于css背景属性的介绍,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。
1、css背景属性之为内容设置背景色:background-color;
属性:
颜色;
inherit;继承父级样式
box.html
背景 <p为内容设置背景色:background-color;
box.css
立即学习“前端免费学习笔记(深入)”;
body{ background-color:#123456;}
2、css背景属性之为内容设置背景为图片background-image:url();
box.css
body{ background-color:#123456; background-image:url(image.png); }
3、css背景属性之固定背景图片background-attachment
(在CSS中使用 background-attachment属性可以将图片固定在浏览器上,如果拖动滚动条,背景图片不会随着网页内容的滚动而滚动,像文字浮在图片上)
属性值:
scroll;背景图片随内容滚动,默认值
fixed; 背景图片固定,不随内容滚动
inherit;继承父类样式
box.css
立即学习“前端免费学习笔记(深入)”;
body{ background-color:#123456; background-image:url(image.png); background-attachment:fixed; font-size: 45px; }
4、css背景属性之背景图片平铺background-repeat;
属性值:
repeat;平铺背景图片;默认
no-repeat;不平铺图片;
repeat-x;在水平方向平铺
repert-y;在竖直方向平铺
box.css
立即学习“前端免费学习笔记(深入)”;
body{ background-color:#123456; background-image:url(image.png); background-attachment:fixed; font-size: 45px; background-repeat: repeat-y; }
5、css背景属性之背景图片定位background-position
属性值:
top;顶部
center;中间
bottom;底部
right;右边
left;左边
inherit;继承父类样式
样式:
xxxpx,xxxpx;
xxx%,xxx%;
xxxpx,top;
box.css
立即学习“前端免费学习笔记(深入)”;
body{ background-color:#123456; background-image:url(image.png); background-attachment:fixed; font-size: 45px; background-repeat:no-repeat; background-position:left; }
相关推荐:
你不知道的CSS背景—css背景属性全解
详解css之背景background属性
以上就是css中背景相关的属性是哪些?css背景属性的介绍的详细内容,更多请关注创想鸟其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/1611206.html
微信扫一扫
支付宝扫一扫