不明白为什么鼠标放上去图标向上消失然后就不出来了,再放一次才会有时候出来有时候不出来

来源:7-1 JS动画案例

用户1079409

2016-12-02 13:40

<!DOCTYPE html>

<html>

<head>

<title></title>

<meta charset = "utf-8">

<style type="text/css">

* {

margin: 0;

padding: 0;

}

#move {

width: 300px;

height: 170px;

margin: 10px auto;

border: 1px solid #ccc;

}

#move a {

display: inline-block;

width: 58px;

height: 25px;

border: 1px solid #ddd;

border-radius: 3px;

background-color: #fff;

text-align: center;

margin: 10px 17px;

position: relative;

padding-top: 40px;

color: #9c9c9c;

font-size: 12px;

text-decoration: none;

line-height: 25px;

overflow: hidden;

}

#move a i {

position: absolute;

top: 20px;

left: 0;

display: inline-block;

width: 100%;

text-align: center;

opacity: 1;

filter: Alpha(opacity=100);

}

#move img {

/*padding: 3px 0;*/

border: none;

/*z-index:-1*/

}

#move a:hover {

color: #f00;

}

</style>

<script type="text/javascript" src="运动框架.js"></script>

<script type="text/javascript">

window.onload = function(){

var oMove = document.getElementById('move');

var aList = oMove.getElementsByTagName('a');

for (var i = 0; i < aList.length; i++) {

aList[i].onmouseover = function() {

var _this = this.getElementsByTagName('i')[0];

startMove(_this,{top:-25,opacity:0},function(){

_this.style.top = 30+'px';

startMove(_this,{top:20,opacity:100});

});

}

};

}

</script>

</head>

<body>

<div id="move">

<a href="#">

<i><img src="jsimages/food.png"></i>

<p>食物</p>

</a>

<a href="#">

<i><img src="jsimages/game.png"></i>

<p>游戏</p>

</a>

<a href="#">

<i><img src="jsimages/insurance.png"></i>

<p>保险</p>

</a>

<a href="#">

<i><img src="jsimages/lottery.png"></i>

<p>彩票</p>

</a>

<a href="#">

<i><img src="jsimages/movie.png"></i>

<p>电影</p>

</a>

<a href="#">

<i><img src="jsimages/travel.png"></i>

<p>旅游</p>

</a>

</div>

</body>

</html>


写回答 关注

2回答

  • 慕粉4375660
    2016-12-31 22:14:49

    我也出现的这个问题。调js文件,格式是对的

  • yiyi37
    2016-12-05 10:14:38

    <script type="text/javascript" src="运动框架.js"></script>

    <script type="text/javascript">

    调js文件,格式不对。应该是:<script src="js/move.js"></script>
    <script>写窗口加载的内容</script>


JS动画效果

通过本课程JS动画的学习,从简单动画开始,逐步深入各种动画框架封装

113925 学习 · 1443 问题

查看课程

相似问题