2022-03-06 使用CSS3的伪元素选择器实现一个瞄准器效果框

实现需求

在这里插入图片描述

实现思路
  • 给.panel元素的四边上四个折线框,是通过一个个宽高10px的小div只显示两侧边框实现的
  • 上面两个可以直接给.panel添加伪元素选择器::before和::after
  • 下面两个可以再给.panel套一个div.panel-footer,同样给这个元素添加两个伪元素选择器
  • 设置定位:子绝父相
完整代码
html
<div class="panel">
    <div class="panel-footer"></div>
</div>
css
.panel {
    position: relative;
    height: 3.875rem;
    border: 1px solid rgba(25, 186, 136, .17);
    background-image: url("../images/line\(1\).png");
    padding: 0 .0625rem .5rem .0625rem;
    &::before {
        position: absolute;
        top: 0;
        left: 0;
        width: 10px;
        height: 10px;
        border-left: 2px solid #02a6b5;
        border-top: 2px solid #02a6b5;
        content: "1";
    }
    &::after {
        position: absolute;
        top: 0;
        right: 0;
        width: 10px;
        height: 10px;
        border-right: 2px solid #02a6b5;
        border-top: 2px solid #02a6b5;
        content: "1";
    }
    .panel-footer {
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        &::before {
            position: absolute;
            bottom: 0;
            left: 0;
            width: 10px;
            height: 10px;
            border-left: 2px solid #02a6b5;
            border-bottom: 2px solid #02a6b5;
            content: "1";
        }
        &::after {
            position: absolute;
            bottom: 0;
            right: 0;
            width: 10px;
            height: 10px;
            border-right: 2px solid #02a6b5;
            border-bottom: 2px solid #02a6b5;
            content: "1";
        }
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

前端OnTheRun

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值