css background属性

简写
background: background-color background-image background-position/background-size background-repeat background-attachment background-clip background-origin;

background-color: red | #ff0000 | rgb(255,0,0) | transparent (透明,默认) | inherit (继承父元素)
1.只能设置一个
2.transparent在不希望某元素拥有背景色且不希望被用户对浏览器的设置影响时使用
3.填充元素内容、内边距和边框,扩展到元素边框的外边界(不包括外边距)
4.设置一个保证图片不可用时有良好的视觉效果

background-image: url() | none(不显示,默认) | inherit (继承父元素)
1.根据background-repeat的值来设置是否平铺
2.初始图像根据background-position的值放置

background-position: left center | 10% 10% | 10px 10px
1.仅规定一个关键词,第二个值为center
2.仅规定一个值,第二个值为50%
3.background-attachment: fixed时,才能保证该属性在 Firefox 和 Opera 中正常工作

background-size: 10px 10px | 50% 10% | cover | contain
1.只设置一个值,第二个值默认auto
2.cover是使背景图完全覆盖
3.contain是吧图像扩展至最大尺寸,使其宽高完全适应内容区域

background-repeat: repeat(默认) | repeat-x | repeat-y | no-repeat | inherit
1.默认在水平和垂直方向重复

background-attachment: scoll | fixed | inherit
1.scoll表示背景随页面其他部门一起滚动
2.fixed表示背景图像固定

background-clip: border-box | padding-box | content-box
1.content-box表示背景被裁剪到内容框

background-origin: border-box | padding-box | content-box
1.规定background-position相对于什么位置来定位
2.background-attachment: fixed时该属性无效

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值