gpt4 book ai didi

html - 在文本移动动画中添加 FadeOut

转载 作者:行者123 更新时间:2023-11-28 14:48:18 26 4
gpt4 key购买 nike

我是新手,我只想在移动完成后在我的文本移动中添加淡出效果。但问题是我已经将@keyframe 淡出。和.fadeout。但它没有用。有什么帮助吗?谢谢。这是代码。

HTML

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<h1>Watch me move</h1>

</body>
</html>

CSS

    body {
font-family: sans-serif;
margin: 50px;
}

h1 {
animation: move 8s;
-webkit-animation: move 8s;
}

@keyframes move {
from {
margin-left: 100%;
width: 300%;
}

to {
margin-left: 0%;
width: 100%;
background:linear-gradient(transparent 150px, white);
}
}

@-webkit-keyframes move {
from {
margin-left: 100%;
width: 300%;
}

to {
margin-left: 0%;
width: 100%;
}

}
@-webkit-keyframes fadeOut {
0% {opacity: 1;}
100% {opacity: 0;}
}

@keyframes fadeOut {

}

.fadeOut {
-webkit-animation-name: fadeOut;
animation-name: fadeOut;
}

最佳答案

除非你有理由将它分开,否则你可以通过向它添加一个步骤将它们全部放在同一个动画中,如下所示:

body {
font-family: sans-serif;
margin: 50px;
}

h1 {
animation: move 3s forwards;
-webkit-animation: move 3s forwards;
}

@keyframes move {
from {
margin-left: 100%;
width: 300%;
}

90% {
margin-left: 0%;
width: 100%;
background:linear-gradient(transparent 150px, white);
opacity: 1;
}
to {
opacity: 0;
}
}

@-webkit-keyframes move {
from {
margin-left: 100%;
width: 300%;
}

90% {
margin-left: 0%;
width: 100%;
opacity: 1;
}

to {
opacity: 0;
}
}
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<h1>Watch me move</h1>

</body>
</html>

关于html - 在文本移动动画中添加 FadeOut,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51974779/

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