• 44.纯 CSS 创作背景色块变换的按钮特效


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

    感想: 伪元素作为背景变化。

    HTML code:

    <nav>
        <ul>
            <li>
                <span>h</span>
                <span>o</span>
                <span>m</span>
                <span>e</span>
            </li>
            <li>
                <span>p</span>
                <span>r</span>
                <span>o</span>
                <span>d</span>
                <span>u</span>
                <span>c</span>
                <span>t</span>
                <span>s</span>
            </li>
            <li>
                <span>s</span>
                <span>e</span>
                <span>v</span>
                <span>i</span>
                <span>c</span>
                <span>e</span>
                <span>s</span>
            </li>
            <li>
                <span>c</span>
                <span>o</span>
                <span>n</span>
                <span>t</span>
                <span>a</span>
                <span>c</span>
                <span>t</span>
            </li>
        </ul>
    </nav>

    CSS code:

    html, body,ul {
        margin: 0;
        padding: 0;
    }
    ul{
        list-style: none;
    }
    body{
        height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
        background: linear-gradient(to right bottom, dimgray, black);
    }
    /* 单词左侧加一条鼠标悬停时变亮的竖线 */
    li{
        margin: 1em 0;
        padding-left: 2em;
        border: 2px solid transparent;
        border-left-color: silver;
        text-align: center;
        transition: 50ms;
    }
    li:hover{
        border-left-color: white;
    }
    
    li:hover span{
        color: #333;
        transition-delay: calc(80ms * var(--n) + 10ms);
    }
    li span{
        position: relative;
        color: white;
        font-size: 50px;
        font-family: monospace;
        text-transform: uppercase;
        letter-spacing: 0.1em;
        /* 定义过渡所花时间 */
        transition: 500ms;
    }
    li span::before{
        position: absolute;
        content:'';
        height: 100%;
        width: 0;
        z-index: -1;
        transition: 500ms;
    }
    li:hover span::before{
        width: 70%;
        transform: rotate(-25deg);
        background: white;
        transition-delay: calc(80ms * var(--n));
    }
    li span:nth-child(1) {
        --n: 1;
    }
    li span:nth-child(2) {
        --n: 2;
    }
    li span:nth-child(3) {
        --n: 3;
    }
    li span:nth-child(4) {
        --n: 4;
    }
    li span:nth-child(5) {
        --n: 5;
    }
    li span:nth-child(6) {
        --n: 6;
    }
    li span:nth-child(7) {
        --n: 7;
    }
    li span:nth-child(8) {
        --n: 8;
    }
  • 相关阅读:
    本周个人总结(14周)
    本周个人总结
    排球计分规则
    我与计算机
    Tomcat处理HTTP请求原理
    数据结构与算法之排序算法(四):归并排序
    数据结构与算法之排序算法(三):选择排序
    数据结构与算法之排序算法(二):交换排序
    数据结构与算法之排序算法(一):插入排序
    数据结构与算法:概述+思维导图
  • 原文地址:https://www.cnblogs.com/FlyingLiao/p/10451502.html
Copyright © 2020-2023  润新知