css彩色字体

css彩色字体

效果展示

thanks

html代码

<body>
    <figure class="neon">
        <p class="text" data-text="thanks">thanks</p>
        <div class="gradient"></div>
        <div class="spotlight"></div>
    </figure>
</body>

css代码

body {
    margin: 0;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: black;
}

.neon {
    position: relative;
    overflow: hidden;
    user-select: none;
}

.text {
    color: white;
    font-size: 150px;
    font-weight: bold;
    font-family: sans-serif;
    text-transform: uppercase;
    margin: 0;
    filter: brightness(2);
    background-color: black;
}

.text::before {
    content: attr(data-text);
    position: absolute;
    filter: blur(3px);
    mix-blend-mode: difference;
}

.gradient {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, red, gold, lightgreen, gold, red);
    mix-blend-mode: multiply;
}

.spotlight {
    position: absolute;
    top: -200%;
    left: -100%;
    right: -100%;
    bottom: -200%;
    background: radial-gradient(circle, white, black 25%)
        center / 5% 5%;
    transform: rotate(45deg);
    mix-blend-mode: color-dodge;
    animation: light 10s linear infinite;
}

@keyframes light {
    to {
        transform: translate(25%, 25%);
    }
}
© 版权声明
THE END
喜欢就支持一下吧
点赞14赞赏 分享
评论 共1条

请登录后发表评论