[CSS3] Background

background: image | position | size | repeat | attachment | clip |origin

(1) 基础

background-color
background-image: url();
background-repeat: repeat-x repeat-y
background-attachment: scroll fixed
(背景图片是否随着页面滚动)
(取值fixed的时候, 一般用在html或body上面 其他标签达不到目的)
background-position: center left right top bottom

这里写图片描述


(2) Updata

[1] background-origin

div{
    display: inline-block;
    padding:30px;
    width:100px;
    height:100px;
    margin:10px;
    border:25px solid green;
    background:url(../1.jpg) no-repeat;
    font-weight: bold;
}

.div2{
    /*以内容为起点*/
    background-origin:content-box;
}
.div3{
   /*以padding为起点*/
    background-origin:padding-box;
}
.div4{
   /*以border为起点*/
    background-origin:border-box;
}

这里写图片描述

这里写图片描述


[2] background-clip

将background-orign-> 改成 clip
这里写图片描述

其实background-clip: 决定背景在哪些区域显示。
(1) 值为border = border+补白+content
(2) 值为padding= 补白+content
(3) 值为content =content

background-origin & clip区别:

background-orign指的是 从哪个位置显示
background-clip更多的是关注 clip 修剪, 在哪个位置显示

background-orign
这里写图片描述
background-clip
这里写图片描述


[3] background-size

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

background-size: cover是填充
background-size: contain是图片等比例的缩放 缩放到宽度或者高度适合


[4] background-break

内联元素 定义背景方式

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值