CSS3中怎么实现曲线阴影和翘边阴影效果,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS3实现曲线阴影和翘边阴影</title>
<style>
body {
font-family: "微软雅黑", "Microsoft YaHei";
font-size: 20px;
}
body, ul, li, h2 {
padding: 0;
margin: 0;
}
ul {
list-style: none outside none;
}
.wrap {
width: 70%;
height: 200px;
margin: 50px auto;
background-color: #fff;
}
.wrap h2 {
font-size: 40px;
text-align: center;
line-height: 200px;
}
.effect {
position: relative;
-webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;
-moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;
-o-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;
}
.effect::after,.effect::before {
content: '';
background: #f00;
position: absolute;
top: 50%;
bottom: 0;
left: 20px;
right: 20px;
-webkit-box-shadow: 0 0 20px rgba(0,0,0,0.8);
-moz-box-shadow: 0 0 20px rgba(0,0,0,0.8);
-o-box-shadow: 0 0 20px rgba(0,0,0,0.8);
box-shadow: 0 0 20px rgba(0,0,0,0.8);
border-radius: 100px/10px;
z-index: -1;
}
.box {
width: 980px;
height: auto;
clear: both;
overflow: hidden;
margin: 20px auto;
}
.box li {
width: 300px;
height: 210px;
float: left;
margin: 20px 10px;
border: 2px solid #EFEFEF;
-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;
-o-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;
position: relative;
background-color: #FFF;
}
.box li img {
display: block;
width: 290px;
height: 200px;
margin: 5px;
}
.box li:before {
content: '';
position: absolute;
width: 90%;
height: 80%;
left: 20px;
bottom: 8px;
background-color: transparent;
box-shadow: 0 8px 20px rgba(0,0,0,0.6);
-webkit-box-shadow: 0 8px 20px rgba(0,0,0,0.6);
-moz-box-shadow: 0 8px 20px rgba(0,0,0,0.6);
-o-box-shadow: 0 8px 20px rgba(0,0,0,0.6);
-webkit-transform: skewX(-11deg) rotate(-4deg);
-moz-transform: skewX(-11deg) rotate(-4deg);
-ms-transform: skewX(-11deg) rotate(-4deg);
-o-transform: skewX(-11deg) rotate(-4deg);
transform: skewX(-11deg) rotate(-4deg);
z-index: -1;
}
.box li:after {
content: '';
position: absolute;
width: 90%;
height: 80%;
right: 20px;
bottom: 8px;
background-color: transparent;
box-shadow: 0 8px 20px rgba(0,0,0,0.6);
-webkit-box-shadow: 0 8px 20px rgba(0,0,0,0.6);
-moz-box-shadow: 0 8px 20px rgba(0,0,0,0.6);
-o-box-shadow: 0 8px 20px rgba(0,0,0,0.6);
-webkit-transform: skewX(11deg) rotate(4deg);
-moz-transform: skewX(11deg) rotate(4deg);
-ms-transform: skewX(11deg) rotate(4deg);
-o-transform: skewX(11deg) rotate(4deg);
transform: skewX(11deg) rotate(4deg);
z-index: -1;
}
</style>
</head>
<body>
<div class="wrap effect">
<h2>Shadow Effect</h2>
</div>
<ul class="box">
<li><img src="images/1.jpg" alt="1.jpg"></li>
<li><img src="images/2.jpg" alt="2.jpg"></li>
<li><img src="images/3.jpg" alt="3.jpg"></li>
</ul>
</body>
</html>
关于CSS3中怎么实现曲线阴影和翘边阴影效果问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注编程网行业资讯频道了解更多相关知识。