gpt4 book ai didi

html - html中的文字动画

转载 作者:行者123 更新时间:2023-11-28 12:35:18 24 4
gpt4 key购买 nike

我有两段文字。我想为这段文字制作动画。我真正想要的是在 x 轴上从左移动第一段,在 x 轴上将第二段从右移动到左。

我的代码只对一个方向起作用,要么向左要么向右。

这里:

<!DOCTYPE html>
<html>
<head>
<style>

#text {
position:relative;
-webkit-animation: mymove infinite; /* Chrome, Safari, Opera */
-webkit-animation-duration: 2s; /* Chrome, Safari, Opera */
animation: mymove infinite;
animation-duration: 2s;
}

/* Chrome, Safari, Opera */
@-webkit-keyframes mymove {
from {top: 200px;}
to {top: 0px;}
}

@keyframes mymove {
from {top: 0px;}
to {top: 100px;}
}

#text1 {
position:relative;
-webkit-animation: mymove infinite; /* Chrome, Safari, Opera */
-webkit-animation-duration: 2s; /* Chrome, Safari, Opera */
animation: mymove infinite;
animation-duration: 2s;
}

/* Chrome, Safari, Opera */
@-webkit-keyframes mymove {
from {right: -200px;}
to {right: 0px;}
}

@keyframes mymove {
from {top: 0px;}
to {top: 100px;}
}

</style>
</head>
<body>
<p id="text">Some text goes here</p>
<p id="text1">text display animation</p>
</body>
</html>

我想将第二段从右移到左,将第一段从左移到右。可能的解决方案是什么?

最佳答案

DEMO

#text {
position:relative;
-webkit-animation: mymove infinite; /* Chrome, Safari, Opera */
-webkit-animation-duration: 2s; /* Chrome, Safari, Opera */
animation: mymove infinite;
animation-duration: 2s;
}

/* Chrome, Safari, Opera */
@-webkit-keyframes mymove {
from {left: 200px;}
to {left: 0px;}
}

@keyframes mymove {
from {left: 200px;}
to {left: 0px;}
}

#text1 {
position:relative;
-webkit-animation: mymove1 infinite; /* Chrome, Safari, Opera */
-webkit-animation-duration: 2s; /* Chrome, Safari, Opera */
animation: mymove1 infinite;
animation-duration: 2s;
}

/* Chrome, Safari, Opera */
@-webkit-keyframes mymove1 {
from {right: 200px;}
to {right: 0px;}
}

@keyframes mymove1 {
from {right: 200px;}
to {right: 0px;}
}

关于html - html中的文字动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27813531/

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