Geo*_*rge 9 css html5 animation css3
考虑使用船舶在蓝色div上方移动的CSS3动画.由于某种原因,船没有移动.HTML如下:
<div id="wrapper">
<div id="sea">
<img src="ship.png" alt="ship" width="128" height="128"/>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
为了制作CSS3动画,我使用以下内容:
#wrapper { position:relative;top:50px;width:700px;height:320px;
margin:0 auto;background:white;border-radius:10px;}
#sea { position:relative;background:#2875DE;width:700px;height:170px;
border-radius:10px;top:190px; }
#sea img {
position:relative;left:480px;top:-20px;
animation:myship 10s;
-moz-animation:myship 10s; /* Firefox */
-webkit-animation:myship 10s; /* Safari and Chrome */
@keyframes myship {
from {left: 480px;}
to{left:20px;}
}
@-moz-keyframes myship {
from {left: 480px;}
to {left:20px;}
}
@-webkit-keyframes myship {
from {left: 480px;}
to{left:20px;}
}
}
Run Code Online (Sandbox Code Playgroud)
船舶图像没有移动.任何帮助是极大的赞赏.
Tho*_*nes 10
你必须在css选择器之外声明你的关键帧,以及为绝对定位的元素设置动画.
你修改过的css看起来像这样:
#wrapper{
position:relative;
top:50px;
width:700px;
height:320px;
margin:0 auto;
background:white;
border-radius:10px;
}
#sea{
position:relative;
background:#2875DE;
width:700px;
height:170px;
border-radius:10px;
top:190px;
}
#sea img{
position:absolute;
left:480px;
top:-20px;
animation:myship 10s;
-moz-animation:myship 10s; /* Firefox */
-webkit-animation:myship 10s; /* Safari and Chrome */
}
@keyframes myship{
from {left: 480px;}
to{left:20px;}
}
@-moz-keyframes myship{
from {left: 480px;}
to{left:20px;}
}
@-webkit-keyframes myship{
from {left: 480px;}
to{left:20px;}
}?
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
44049 次 |
| 最近记录: |