记录一下box-shadow的扩展使用。利用多投影(倾斜投影与主体投影)重叠的原理,实现曲线阴影与翘边阴影的效果:
慕课网视频地址
效果图:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>img wall</title>
<link rel="stylesheet" href="img.css">
</head>
<body>
<div class="wrap effect">
<h1>shadow effect</h1>
</div>
<ul class="box">
<li><img src="./img/photo1.jpg" alt=""></li>
<li><img src="./img/photo2.jpg" alt=""></li>
<li><img src="./img/photo3.jpg" alt=""></li>
</ul>
</body>
</html>
img.css
body{
font-family: Arial;
font-size: 23px;
}
.wrap h1{
text-align: center;
position: relative;
top: 50px;
}
.wrap{
width: 70%;
height: 200px;
background: #fff;
margin: 40px auto;
}
.effect{
position: relative;
box-shadow: 0 1px 4px rgba(0,0,0,0.3),0 0 40px rgba(0,0,0,0.1) inset;
}
.effect:before,.effect:after{
content: '';
z-index: -1;
position: absolute;
box-shadow: 0 0 20px rgba(0,0,0,0.8) ;
top:50%;
bottom: 0;
left: 10px;
right: 10px;
border-radius: 100px/10px;
}
.box{
width: 980px;
height: auto;
margin: 20px auto;
padding:0;
clear: both;
overflow: hidden;
}
.box li{
list-style-type: none;
margin: 20px 10px;
padding: 0;
width: 300px;
height: 220px;
border: 2px solid #efefef;
position: relative;
float: left;
background: #ffffff;
line-height: 220px;
-webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27),0 0 60px rgba(0,0,0,0.1) inset;
-moz-box-shadow:0 1px 4px rgba(0, 0, 0, 0.27),0 0 60px rgba(0,0,0,0.1) inset;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27),0 0 60px rgba(0,0,0,0.1) inset;
}
.box li img{
width: 290px;
height: 210px;
padding: 5px;;
}
.box li:before{
position: absolute;
background: transparent;
z-index: -1;
width: 90%;
height: 80%;
content: '';
left: 20px;
bottom: 8px;
transform: skew(-12deg) rotate(-4deg);
-webkit-box-shadow: 0 8px 20px rgba(0,0,0,0.6);
-moz-box-shadow: 0 8px 20px rgba(0,0,0,0.6);
box-shadow: 0 8px 20px rgba(0,0,0,0.6);
}
.box li:after{
position: absolute;
background: transparent;
z-index: -1;
width: 90%;
height: 80%;
content: '';
left: 20px;
bottom: 8px;
transform: skew(12deg) rotate(4deg);
-webkit-box-shadow: 0 8px 20px rgba(0,0,0,0.6);
-moz-box-shadow: 0 8px 20px rgba(0,0,0,0.6);
box-shadow: 0 8px 20px rgba(0,0,0,0.6);
}
网友评论