zoukankan      html  css  js  c++  java
  • 9.纯 CSS 创作一种按钮被瞄准的交互特效

    原文地址:https://segmentfault.com/a/1190000014680999

    吃鸡倍镜,哈哈哈

    HTML代码:

    <div class="box">
           <span>BUTTON</span>
           <span class="left"></span>
           <span class="right"></span>
           <span class="top"></span>
           <span class="bottom"></span>
    </div>

    CSS代码:

    html, body {
        margin: 0;
        padding: 0;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        color: black;
    }
    .box{
        width:9em;
        height:3em;
        text-align: center;
        line-height: 3em;
        font-size: 30px;
        /* 字母间距 */
        letter-spacing: 0.2em;
        position: relative;
        filter: blur(2px);
        transition: 1s;
    }
    .box:hover {
        filter: blur(0.2px);
    }
    .box::after {
        content: '';
        position: absolute;
        width: 3em;
        height: 3em;
        border: 1px solid red;
        border-radius: 50%;
        left: 3em;
        filter: opacity(0);
    }
    .box span:not(:first-child) {
        position: absolute;
        background-color: red;
        filter: opacity(0);
    }
    
    .box:hover::after,
    .box:hover span:not(:first-child) {
        animation: aim 1s linear infinite alternate;
    }
    
    .box span.top,
    .box span.bottom {
        width: 1px;
        height: 3em;
        left: 50%;
    }
    .box span.top {
        top: -3em;
    }
    .box span.bottom {
        bottom: -3em;
    }
    .box span.left,
    .box span.right {
        width: 3em;
        height: 1px;
        top: 50%;
    }
    .box span.left {
        left: 0;
    }
    .box span.right {
        right: 0;
    }
    @keyframes aim {
        from {
            filter: opacity(0.2);
        }
        to {
            filter: opacity(0.8);
        }
    }
  • 相关阅读:
    扫描线算法
    评论备份(3)
    评论备份(2)
    二分法的注意事项
    sam模板
    Machine Learning(Andrew Ng)学习笔记
    洛谷P2221 [HAOI2012]高速公路
    洛谷P3233 [HNOI2014]世界树
    P2515 [HAOI2010]软件安装
    BZOJ4293: [PA2015]Siano
  • 原文地址:https://www.cnblogs.com/FlyingLiao/p/10120024.html
Copyright © 2011-2022 走看看