- 先看一下我们要实现的效果图
道理很简单,就是通过几个元素阴影叠加,生成我们看到的这种效果,主要是对阴影样式的运用,以及 before 和 after 元素的运用,直接上代码:
html 代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS3实现曲线阴影和翘边阴影</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div class="wrap effect">
<h1>shadow effect</h1>
</div>
</body>
</html>
css 样式代码:
/*
**author:青天诀;
*/
body,h1,ul,li{
margin: 0;
padding: 0;
}
body{
font-family: Arial;
font-size: 20px;
}
ul,li{
list-style: none;
}
.wrap{
width: 50%;
height: 200px;
background-color: #fff;
margin: 50px auto;
position: relative;
}
.wrap h1{
line-height: 200px;
text-align: center;
font-size: 20px;
}
.effect{
-webkit-box-shadow: 0px 1px 4px rgba(0,0,0,.3), 0px 0px 40px rgba(0,0,0,.1) inset;
-moz-box-shadow: 0px 1px 4px rgba(0,0,0,.3), 0px 0px 40px rgba(0,0,0,.1) inset;
-o-box-shadow: 0px 1px 4px rgba(0,0,0,.3), 0px 0px 40px rgba(0,0,0,.1) inset;
-mz-box-shadow: 0px 1px 4px rgba(0,0,0,.3), 0px 0px 40px rgba(0,0,0,.1) inset;
box-shadow: 0px 1px 4px rgba(0,0,0,.3), 0px 0px 40px rgba(0,0,0,.1) inset;
}
.effect:before, .effect:after{
content: "";
background-color: red;
position: absolute;
z-index: -1;
left: 10px;
right: 10px;
top: 50%;
bottom: 0px;
-webkit-box-shadow: 0px 0px 20px rgba(0,0,0,.8);
-moz-box-shadow: 0px 0px 20px rgba(0,0,0,.8);
-o-box-shadow: 0px 0px 20px rgba(0,0,0,.8);
-mz-box-shadow: 0px 0px 20px rgba(0,0,0,.8);
box-shadow: 0px 0px 20px rgba(0,0,0,.8);
border-radius: 50px;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-10-03 22:38:40