目录
*** css3背景 ***
-
背景图像区域
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Clip</title>
<style type="text/css">
* {
margin: 0;
padding: 0;
border: none;
}
div {
width: 800px;
height: 400px;
padding: 50px;
border: 50px solid transparent; /*边框透明*/
background: url('bg1.jpg') no-repeat center center;
background-clip: border-box;
background-clip: padding-box;
background-clip: content-box;
}
span.div_border { /*虚拟边框*/
position: absolute;
top: 0;
left: 0;
width: 800px;
height: 400px;
padding: 50px;
border: 50px solid rgba(255, 0, 0, .25);
}
span.div_padding { /*虚拟div填充*/
position: absolute;
top: 50px;
left: 50px;
width: 800px;
height: 400px;
border: 50px solid rgba(255, 255, 0, .25);
}
</style>
</head>
<body>
<div></div>
<span class="div_border"></span>
<span class="div_padding"></span>
</body>
</html>
-
背景图像定位
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Clip</title>
<style type="text/css">
* {
margin: 0;
padding: 0;
border: none;
}
div {
width: 800px;
height: 400px;
padding: 50px;
border: 50px solid transparent;
background: url('bg1.jpg') no-repeat 50px 100px;
background-origin: border-box;
background-origin: padding-box;
background-origin: content-box;
}
span.div_border {
position: absolute;
top: 0;
left: 0;
width: 800px;
height: 400px;
padding: 50px;
border: 50px solid rgba(255, 0, 0, .25);
}
span.div_padding {
position: absolute;
top: 50px;
left: 50px;
width: 800px;
height: