<!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 背景被裁剪到内容框。
效果图:
本文展示了CSS背景裁剪属性(background-clip)在不同盒模型(content-box, padding-box, border-box)下的效果,包括内容盒、内边距盒和边框盒,并通过实例进行说明。
2827

被折叠的 条评论
为什么被折叠?



