【发布时间】:2022-01-08 17:57:52
【问题描述】:
我正在尝试在 id="hello" 元素上执行动画,动画在右边距上不起作用,但在左边距上完美运行,请问有什么想法吗?
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
#hola {
width: 250px;
height: 250px;
background-color: red;
animation-name: hola;
animation-duration: 2s;
animation-fill-mode: forwards;}
#hello {
width: 250px;
height: 250px;
background-color: red;
animation-name: hello;
animation-duration: 2s;
animation-fill-mode: forwards;}
@keyframes hola {
from {
` margin-left: -250px;
}
to {
margin-left: 10px;
}}
@keyframes hello {
from {
margin-right: 10px;}
to {
margin-right: 1000px;}}
</style>
<title>Document</title>
</head>
<body>
<div>
<h1>My tranforming element</h1>
<div id="hola"><p>Hola</p></div>
<div id="hello"><p>Hello</p></div>
</div>
</body>
</html>
【问题讨论】:
标签: html css css-animations