gpt4 book ai didi

javascript - 如何在重叠图像时更改字体颜色?

转载 作者:行者123 更新时间:2023-11-29 22:45:34 24 4
gpt4 key购买 nike

前几天我看到了这个网站https://bahaasamir.me我想知道如何复制这种文字效果?我的意思是在重叠图像(CSS 或 JS)时将黑色更改为白色。我试过使用混合模式,但结果并不尽如人意。有关如何实现这种效果的任何见解或方向?

最佳答案

您有几个选择。您可以选择自己编写脚本和 css 动画,也可以使用库

animejs

另一种选择是使用 CSS 动画

.element {
height: 250px;
width: 250px;
margin: 0 auto;
background-color: red;
animation-name: stretch;
animation-duration: 1.5s;
animation-timing-function: ease-out;
animation-delay: 0;
animation-direction: alternate;
animation-iteration-count: infinite;
animation-fill-mode: none;
animation-play-state: running;
}

@keyframes stretch {
0% {
transform: scale(.3);
background-color: red;
border-radius: 100%;
}
50% {
background-color: orange;
}
100% {
transform: scale(1.5);
background-color: yellow;
}
}

body,
html {
height: 100%;
}

body {
display: flex;
align-items: center;
justify-content: center;
}
<div class="element"></div>

只需检查 CSS 文本动画

@import "compass/css3";

@import url(https://fonts.googleapis.com/css?family=Finger+Paint);

body {
background: black;
overflow: hidden;
font: 5vw/100vh "Finger Paint";
text-align: center;
color: transparent;
backface-visibility: hidden;
}

span {
display: inline-block;
text-shadow: 0 0 0 whitesmoke;
animation: smoky 5s 3s both;
}

span:nth-child(even){
animation-name: smoky-mirror;
}

@keyframes smoky {
60% {
text-shadow: 0 0 40px whitesmoke;
}
to {
transform:
translate3d(15rem,-8rem,0)
rotate(-40deg)
skewX(70deg)
scale(1.5);
text-shadow: 0 0 20px whitesmoke;
opacity: 0;
}
}

@keyframes smoky-mirror {
60% {
text-shadow: 0 0 40px whitesmoke; }
to {
transform:
translate3d(18rem,-8rem,0)
rotate(-40deg)
skewX(-70deg)
scale(2);
text-shadow: 0 0 20px whitesmoke;
opacity: 0;
}
}

@for $item from 1 through 21 {
span:nth-of-type(#{$item}){
animation-delay: #{(3 + ($item/10))}s;
}
}
<span>C</span><span>S</span><span>S</span><span>&nbsp;</span><span>S</span><span>m</span><span>o</span><span>k</span><span>y</span><span>&nbsp;</span><span>T</span><span>e</span><span>x</span><span>t</span><span>&nbsp;</span><span>E</span><span>f</span><span>f</span><span>e</span><span>c</span><span>t</span>

Free Examples

关于javascript - 如何在重叠图像时更改字体颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58783249/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com