我有兩段文字。我想動畫這個文本。我真正想要的是在x軸上從左側移動第一段,從右側移動到第二段。HTML中的文字動畫
我的代碼只能用於一個方向,無論是向左還是向右。
這裏:
<!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>
我想第二款從右到左,從左至右第一個移動。 可能的解決方案是什麼?
正是由於 'mymove' 的重名。爲每個動畫使用一些唯一的ID。 –