不用多层div嵌套,不用图片,我们只要用简单的CSS就能实现多层边框的效果,其方法是通过:after 和 :before 伪类。效果如下图。
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Multiple Borders with Simple CSS </title>
<style type="text/css">
#box{
position: relative;
width: 400px;
height: 400px;
margin: 100px auto;
background: #efefef;
border: 1px solid #bfbfbf;
}
#box:before {
position: absolute;
width: 388px;
height: 388px;
border: 6px solid white;
content: '';
}
#box:after {
position: absolute;
left: 6px;
top: 6px;
width: 386px;
height: 386px;
border: 1px dashed pink;
content: '';
}
</style>
</head>
<body>
<div id="box">
<img src="http://www.funnyapple.com/uploads/2010/07/multi-border.jpg"
alt=""/>
</div>
</body>
</html>
查看Demo
有3 位同学留下了脚印
jessica好样的。我要对你笑一个
没关系,我的眼皮能顶住。。我继续看你其它的文章去。。
这个方法是不错,可惜不能兼容ie6