Css制作hover下划线动画

2020-09-03 10:41:16 浏览数 (2)

代码语言:javascript复制
    .demo {
        position: relative;
        font-size: 20px;
        display: inline-block;
        cursor: pointer;
    }

    .demo:before {
        content: "";
        position: absolute;
        left: 50%;
        bottom: -2px;
        width: 0;
        height: 2px;
        background: #4285f4;
        transition: all .3s;
    }

    .demo:hover:before {
        width: 100%;
        left: 0;
        right: 0;
    }
代码语言:javascript复制
 <div class="demo">自己实现的hover效果</div>

0 人点赞