css3的background-clip 背景

本文展示了CSS背景裁剪属性(background-clip)在不同盒模型(content-box, padding-box, border-box)下的效果,包括内容盒、内边距盒和边框盒,并通过实例进行说明。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
.c-box{
    width:100px;
    height:100px;
    padding:20px;
    background-color:#0FF;
    background-clip: content-box;
    border:2px solid #92b901;
}
.p-box{
    width:100px;
    height:100px;
    padding:10px;
    background-color:#0F0;
    background-clip: padding-box;
    border:10px dashed #92b901;
}
.b-box{
    width:100px;
    height:100px;
    padding:10px;
    background-color:#FF0;
    background-clip: border-box;
    border:5px dashed #92b901;
}
</style>
<title>无标题文档</title>

</head>

<body>

<div class="c-box">
     content-box 的效果
</div>
<br />
<div class="p-box">
     padding-box 的效果
</div>
<br />
<div class="b-box">
    border-box 的效果
</div>
</body>
</html>


浏览器支持

IE9+、Firefox、Opera、Chrome 以及 Safari 支持 background-clip 属性。

注释:Internet Explorer 8 以及更早的版本不支持 background-clip 属性。

border-box       背景被裁剪到边框盒。

padding-box    背景被裁剪到内边距框。

content-box     背景被裁剪到内容框。

效果图:


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值