只在容器一边或两边显示盒子阴影

2020-07-01  本文已影响0人  两年半练习程序员

实现方案

首先定义一个有具体宽高的盒子,然后正确定位:after伪类。
效果
[图片上传中...(image.png-8e8e17-1593570486291-0)]

底部阴影

代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .box-shadow {
        background-color: #FF8020;
        width: 160px;
        height: 90px;
        position: relative;
    }

    .box-shadow:after {
        content: "";
        width: 150px;
        height: 1px;
        display: block;
        position: absolute;
        bottom: 0px;
        left: 5px;
        z-index: -1;
        -webkit-box-shadow: 0px 0px 8px 2px #000000;
        -moz-box-shadow: 0px 0px 8px 2px #000000;
        box-shadow: 0px 0px 8px 2px #000000;
    }
</style>

<body>
    <div class="box-shadow"></div>
</body>

</html>
上一篇 下一篇

猜你喜欢

热点阅读