【问题标题】:Modifying The Preloader To Output A Different Letter修改预加载器以输出不同的字母
【发布时间】:2021-01-19 12:38:12
【问题描述】:

我有以下预加载代码:

* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

@import url('https://fonts.googleapis.com/css2?family=Montserrat+Alternates:wght@500;700&family=Montserrat:wght@400;600&family=Oswald:wght@500&family=Pacifico&family=Roboto:ital,wght@0,400;0,900;1,500&display=swap');

.container {
    width: 100%;
    height: 100vh;
    display: grid;
    justify-content: center;
    align-items: center;
    background-color: #21252B;
    /* grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); */
}

.svg-file path {
    fill: transparent;
    stroke-width: 3;
    stroke: #89C9B8;
}

.svg-file.z-logo path {
    stroke-dasharray: 550;
    stroke-dashoffset: 0;
}

.svg-file.z-logo path {
    animation: animate-zlogo 3s linear infinite;
}

svg {
    filter: drop-shadow(2px 2px 3px rgba(0, 0, 0, 1));
    transform: scale(2);
}

.svg-file h2 {
    font-family: "Roboto", cursive;
    transform: translate(0, 50px) skewX(-210deg) rotate(-6deg);
    font-size: 3em;
    color: #89C9B8;
}

/* .svg-file h2 span:nth-child(1) {
    animation: fadein-fadeout 1s infinite;
} */

.svg-file span {
    animation: dots 2.5s steps(6, end) infinite;
    font-size: 5em;
    display: block;
    transform: translate(0, 65px) skewX(-210deg) rotate(-6deg);
    background-color: #89C9B8;
    width: 8px;
    height: 5px;
}

/* .svg-file h2 span:nth-last-child(1) {
    animation: fadein-fadeout 2s infinite;
} */

@keyframes dots {

    0%,
    20% {
        background-color: rgb(191, 224, 215, .08);
        box-shadow:
            .25em 0 0 rgba(191, 224, 215, .08),
            .5em 0 0 rgba(191, 224, 215, .08);
    }

    40% {
        background-color: #89C9B8;
        box-shadow:
            .25em 0 0 rgba(191, 224, 215, .08),
            .5em 0 0 rgba(191, 224, 215, .08);
    }

    60% {
        box-shadow:
            .25em 0 0 #89C9B8,
            .5em 0 0 rgba(191, 224, 215, .08);
    }

    80%,
    100% {
        box-shadow:
            .25em 0 0 #89C9B8,
            .5em 0 0 #89C9B8;
    }
}

@keyframes fadein-fadeout {
    0% {
        opacity: 0;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

@keyframes animate-zlogo {
    0% {
        stroke-dashoffset: 0;
    }

    20% {
        stroke-dashoffset: 550;
        fill: transparent;
    }

    40% {
        fill: transparent;
        stroke-dashoffset: 1100;
    }

    60% {
        stroke-dashoffset: 1100;
        fill: #89C9B8;
    }

    80% {
        stroke-width: 0;
        fill: #89C9B8;
    }

    100% {
        /* stroke-dashoffset: 0; */
        stroke-width: 3;
        fill: transparent;
    }
}

/* @keyframes animate-zlogo {
    0% {
        stroke-dashoffset: 0;
    }

    40% {
        stroke-dashoffset: 550;
        fill: transparent;
    }

    60% {
        fill: transparent;
        stroke-dashoffset: 1100;
    }

    80% {
        stroke-dashoffset: 1100;
        fill: #89C9B8;
    }

    100% {
        stroke-width: 0;
        fill: #89C9B8;
    }
} */
    <div class="container">
        <div class="svg-file z-logo">
            <svg width="133" height="119" viewBox="-1 -5 150 119" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path
                    d="M37.5 7.5L26.25 41.25L71.6667 37.5L0 118.75L100.417 112.083L113.75 75L82.5 76.6667L132.083 0L37.5 7.5Z"
                    fill="#47AF9A" />
            </svg>
            <span></span>
        </div>
    </div>

所以我基本上希望输出是H,而不是当前显示的Z。我尝试更改CSS 文件中的测量值,但我会完全得到不同的输出,我基本上想要让它输出字母H 而不是Z

我也尝试在 css 中更改此代码:

@keyframes animate-zlogo {
    0% {
        stroke-dashoffset: 0;
    }

    20% {
        stroke-dashoffset: 550;
        fill: transparent;
    }

    40% {
        fill: transparent;
        stroke-dashoffset: 1100;
    }

    60% {
        stroke-dashoffset: 1100;
        fill: #89C9B8;
    }

    80% {
        stroke-width: 0;
        fill: #89C9B8;
    }

    100% {
        /* stroke-dashoffset: 0; */
        stroke-width: 3;
        fill: transparent;
    }
}

由于这是整个预加载器的动画,并且它控制特定 z 预加载器的动画工作方式,因此我尝试使用不同的测量值更改一些类以查看与 z 不同的输出,以便我将对如何更好地使其输出h 有一个更好的想法,但我目前被困在这部分,并且需要关于我应该调整哪些类的测量/代码的额外帮助。有什么建议吗?

【问题讨论】:

    标签: javascript html css web web-deployment


    【解决方案1】:

    您需要更改 SVG 代码,如下所示:

    * {
        padding: 0;
        margin: 0;
        box-sizing: border-box;
    }
    
    @import url('https://fonts.googleapis.com/css2?family=Montserrat+Alternates:wght@500;700&family=Montserrat:wght@400;600&family=Oswald:wght@500&family=Pacifico&family=Roboto:ital,wght@0,400;0,900;1,500&display=swap');
    
    .container {
        width: 100%;
        height: 100vh;
        display: grid;
        justify-content: center;
        align-items: center;
        background-color: #21252B;
        /* grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); */
    }
    
    .svg-file path {
        fill: transparent;
        stroke-width: 3;
        stroke: #89C9B8;
    }
    
    .svg-file.z-logo path {
        stroke-dasharray: 695;
        stroke-dashoffset: 0;
    }
    
    .svg-file.z-logo path {
        animation: animate-zlogo 3s linear infinite;
    }
    
    svg {
        filter: drop-shadow(2px 2px 3px rgba(0, 0, 0, 1));
        transform: scale(2);
    }
    
    .svg-file h2 {
        font-family: "Roboto", cursive;
        transform: translate(0, 50px) skewX(-210deg) rotate(-6deg);
        font-size: 3em;
        color: #89C9B8;
    }
    
    /* .svg-file h2 span:nth-child(1) {
        animation: fadein-fadeout 1s infinite;
    } */
    
    .svg-file span {
        animation: dots 2.5s steps(6, end) infinite;
        font-size: 5em;
        display: block;
        transform: translate(0, 65px) skewX(-210deg) rotate(-6deg);
        background-color: #89C9B8;
        width: 8px;
        height: 5px;
    }
    
    /* .svg-file h2 span:nth-last-child(1) {
        animation: fadein-fadeout 2s infinite;
    } */
    
    @keyframes dots {
    
        0%,
        20% {
            background-color: rgb(191, 224, 215, .08);
            box-shadow:
                .25em 0 0 rgba(191, 224, 215, .08),
                .5em 0 0 rgba(191, 224, 215, .08);
        }
    
        40% {
            background-color: #89C9B8;
            box-shadow:
                .25em 0 0 rgba(191, 224, 215, .08),
                .5em 0 0 rgba(191, 224, 215, .08);
        }
    
        60% {
            box-shadow:
                .25em 0 0 #89C9B8,
                .5em 0 0 rgba(191, 224, 215, .08);
        }
    
        80%,
        100% {
            box-shadow:
                .25em 0 0 #89C9B8,
                .5em 0 0 #89C9B8;
        }
    }
    
    @keyframes fadein-fadeout {
        0% {
            opacity: 0;
        }
    
        50% {
            opacity: 1;
        }
    
        100% {
            opacity: 0;
        }
    }
    
    @keyframes animate-zlogo {
        0% {
            stroke-dashoffset: -50;
        }
    
        20% {
            stroke-dashoffset: 550;
            fill: transparent;
        }
    
        40% {
            fill: transparent;
            stroke-dashoffset: 1100;
        }
    
        60% {
            stroke-dashoffset: 1100;
            fill: #89C9B8;
        }
    
        80% {
            stroke-width: 0;
            fill: #89C9B8;
        }
    
        100% {
            /* stroke-dashoffset: 0; */
            stroke-width: 3;
            fill: transparent;
        }
    }
    
    /* @keyframes animate-zlogo {
        0% {
            stroke-dashoffset: 0;
        }
    
        40% {
            stroke-dashoffset: 550;
            fill: transparent;
        }
    
        60% {
            fill: transparent;
            stroke-dashoffset: 1100;
        }
    
        80% {
            stroke-dashoffset: 1100;
            fill: #89C9B8;
        }
    
        100% {
            stroke-width: 0;
            fill: #89C9B8;
        }
    } */
    <div class="container">
        <div class="svg-file z-logo">            
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 133 133" width="133" height="133"><g id="H"><path d="M45.33 78.22L87.67 78.22L87.67 133L121.05 133L121.05 0L87.67 0L87.67 49.33L45.33 49.33L45.33 0L11.95 0L11.95 133L45.33 133L45.33 78.22Z" fill="#47AF9A"/></g></svg>
            <span></span>
        </div>
    </div>

    【讨论】:

      猜你喜欢
      • 2017-01-26
      • 2023-04-02
      • 2016-06-08
      • 1970-01-01
      • 1970-01-01
      • 2020-05-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多