51可用代码模板网站

咨询热线:

181-1164-6936
  • 1
CSS样式
当前位置:首页>实用代码>CSS样式>

CSS3曲线阴影与翘角阴影

时间:2017-08-14 15:20点击:

曲线阴影:利用:after和:before伪类创造两个与父级相同的元素,利用border-radius实现曲线阴影。



翘角阴影:同样是利用上面两个伪类创造元素,利用transform变形与旋转实现角度阴影具体代码:


曲线阴影
html


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>CSS3实现曲线阴影和翘边阴影</title>
    <link rel="stylesheet" href="css/style.css">
</head>
<body>
    <div class="wrap curve">
        <h1>Shadow Curve</h1>
    </div>  
</body>
</html>


css


body{
    font-family: Arial;
    font-size: 20px;
}
body,ul{
    list-style: none;
    margin: 0;
    padding: 0;
}
.wrap{
    position: relative;
    width: 60%;
    height: 200px;
    margin: 50px auto;
    text-align: center;
    line-height: 200px;
    background-color:#fff; 
}
.curve{
    height: 200px;
    position: relative;
    box-shadow: 0px 1px 4px 0px rgba(0,0,0,0.3),
                0px 0px 20px rgba(255,0,0,0.1) inset;
}
.curve:after,.curve:before{
    content: '';
    position: absolute;
    z-index: -1;
    top: 50%;
    bottom: 0;
    left: 16px;
    right: 16px;
    background: red;
    box-shadow: 0px 0px 20px rgba(0,0,0,0.8); 
    border-radius: 100px/10px;
}


翘角阴影
HTML


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>CSS翘边阴影</title>
    <link rel="stylesheet" href="css/Alice.css">
</head>
<body>
    <ul> 
        <li>
            <img src="images/photo1.jpg" alt="" />
        </li>
        <li>
            <img src="images/photo2.jpg" alt="" />
        </li>
        <li>
            <img src="images/photo3.jpg" alt="" />
        </li>
    </ul>
</body>
</html>


css


ul{
    width: 1200px;
    height: 240px;
    margin: 50px auto;
    display: flex;
    justify-content: space-between;
}
ul li{
    position: relative;
    width: 340px;
    height:240px;
    float: left;
    box-shadow: 0px 0px 4px rgba(0,0,0,0.3);
    background: #fff;
    display: flex;
    align-items: center; 
    justify-content: center;
}
ul img{
    width: 300px;
    height: 200px;
}
ul li:before,ul li:after{
    content: '';
    position: absolute;
    z-index: -2;
    bottom: 19px;
    width: 90%;
    height: 80%;
    background-color: transparent;
    box-shadow:0px 8px 20px rgba(0,0,0,0.8);
    transform:skewX(10deg) rotate(5deg);
}
ul li:before{
    left: 12px;
}
ul li:after{
    right: 12px;
    transform:skewX(-10deg) rotate(-5deg);
}



51可用模板(代码)网站专为广大站长朋友提供精品模板与代码,同时免费提供网站收录。
本站域名: WWW.51KYDM.COM    联系方式:QQ:182468923    手机:18111646936
本站关键词:网站链接收录网址收录入口网站免费提交收录网站收录提交入口    网站地图
51可用模板
展开