<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style type="text/css">
.walk_show{
width:120px;
height:182px;
border:1px solid #333;
margin:50px auto 0;
overflow:hidden;
position:relative;
}
.walk_show img{
position:absolute;
left:0px;
top:0px;
}
</style>
<script type="text/javascript">
window.onload = function(){
var oImg = document.getElementById('img01');
var nowleft = 0;

function fnMove(){

nowleft -=120;

if(nowleft<-840)
{
nowleft=0;
}

oImg.style.left = nowleft + 'px';
}

setInterval(fnMove,120);

}

</script>
</head>
<body>
<p>使用下面这张图片制作关键帧动画</p>
<img src="images/walking.png" alt="人物走路">
<div class="walk_show">
<img src="images/walking.png" alt="人物走路" id="img01">
</div>
</body>
</html>

JavaScript随写

个人总结:和字符串的拼接,数据库中表的外联一样,调用css中样式属性值进行操作的时候只会生成一个新的,而不会改变css中该属性值,只是重新生成了一个,因此,在循环语句或定时器运用中,对于css样式属性值的修改应采用直接通过变量或数值赋值的方式,才能在网页中准确地动态展现出效果。





相关文章:

  • 2021-06-08
  • 2021-11-19
  • 2022-03-02
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-11
相关资源
相似解决方案