css翅边阴影

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>::before和::after</title>
    <style>
        .effect{
            position: relative;
            width: 50%;
            height: 30%;
            padding: 10%;
            margin: 0 auto;
            box-shadow: 0 1px 4px rgba(0,0,0,0.3),0 0 40px rgba(0,0,0,0.1) inset;
            text-align: center;
            background: #fff; /* 必须设置背景; 但不能有z-index,否则盖不住after内容 */
        }
        .effect:after,.effect:before{
            position: absolute;
            content:"";
            top:50%;
            bottom: -1px;
            left:30px;
            right: 30px;
            box-shadow: 0 0 20px rgba(0,0,0,0.8);
            border-radius: 40%/20%;
            z-index: -2;
        }
    </style>
</head>
<body>
    <div class="effect">
        <h1>shadow effect</h1>
    </div>
</body>
</html>

posted @ 2019-10-10 10:19  森林王子  阅读(158)  评论(0)    收藏  举报