• 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;
    }
  • 相关阅读:
    id4的数据库持久化写法
    docker 加速镜像的地址收集
    mongodb 的ID转换实体要注意的地方
    net core3.0 常用封装状态码总结
    JAVA8—————StringJoiner类
    BigDecimal加减乘除
    mysql 查询奇偶数
    Java遍历Map对象的方式
    Java中List, Integer[], int[]的相互转换
    springboot 读取resources下的文件然后下载
  • 原文地址:https://www.cnblogs.com/FlyingLiao/p/10451502.html
Copyright © 2020-2023  润新知