实现向内凹陷圆角效果

622 阅读1分钟
  • 在原来的容器元素中定义4个角方块
  • 让方块的背景颜色跟容器元素的父级元素的背景相同
  • 分别给每个方块定义圆角,并指定每个方块的边框跟容器元素相同
  • 判断清楚各个方向的圆角位置,以及显示的那条边框
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 400px;
            height: 400px;
            background: mediumaquamarine;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .box .box_div1 {
            width: 320px;
            height: 240px;
            border: 1px solid maroon;
            position: relative;
        }
        .box .box_media{
            width: 100%;
            height: 100%;
        }

        .box_item {
            width: 40px;
            height: 40px;
            background: mediumaquamarine;
            position: absolute;
        }

        .box_item-top_left {
            border-bottom-right-radius: 40px;
            border-bottom: 1px solid maroon;
            border-right: 1px solid maroon;
            left: -1px;
            top: -1px;
        }

        .box_item-top_right {
            right: -1px;
            top: -1px;
            border-bottom-left-radius: 40px;
            border-bottom: 1px solid maroon;
            border-left: 1px solid maroon;
        }

        .box_item-bttom_left {
            bottom: -1px;
            left: -1px;
            border-top-right-radius: 40px;
            border-top: 1px solid maroon;
            border-right: 1px solid maroon;
        }

        .box_item-bottom_right {
            bottom: -1px;
            right: -1px;
            border-top-left-radius: 40px;
            border-top: 1px solid maroon;
            border-left: 1px solid maroon;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="box_div1">
            <div class="box_item box_item-top_left"></div>
            <div class="box_item box_item-top_right"></div>
            <div class="box_item box_item-bttom_left"></div>
            <div class="box_item box_item-bottom_right"></div>
            <video class="box_media" autoplay="" name="media" src="https://www.runoob.com/try/demo_source/movie.mp4">
            </video>
        </div>
    </div>
</body>

</html>