mouse事件(demo:div块变大缩小)

小果浏览博客期间,发现一个很有意思的动画效果,实在喜欢,于是。。。

效果描述:

鼠标进入:div块缓慢变大,周围的div块随着变大,幅度稍小;

鼠标移出:div块缓慢收回,变回原大小;

效果图:

静态图

 

   鼠标进入第1个div块                      鼠标进入第3个div块                         

      

  鼠标进入第5个div块

 

代码实现:

css:

<style>
            ul {
                height: 150px;
                width: 300px;
                background-color: black;
                list-style: none;
            }
            ul>li {
                height: 50px;
                width: 50px;
                margin-top: 80px;
                background-repeat: no-repeat;
                background-size: 100% 100%;
                float: left;
            }
            
            li:nth-of-type(1) {
                background-image: url(img/left.png);
            }
            
            li:nth-of-type(2) {
                background-image: url(img/right.png);
            }
            
            li:nth-of-type(3) {
                background-image: url(img/left.png);
            }
            
            li:nth-of-type(4) {
                background-image: url(img/right.png);
            }
            
            li:nth-of-type(5) {
                background-image: url(img/left.png);
            }
        </style>

body:

<body>
	<div class="container-fluid">
		<ul class="row">
			<li class="col-md-2"></li>
			<li class="col-md-2"></li>
			<li class="col-md-2"></li>
			<li class="col-md-2"></li>
			<li class="col-md-2"></li>
		</ul>
	</div>
</body>

script:

<script src="js/jQuery-1.12.4.min.js"></script>
    <script>
        $("ul li").mousemove(function(){
            $(this).stop().animate({
                width:'75px',
                height:'75px'
            },50);
            $(this).prev(1).stop().animate({
                width:'60px',
                height:'60px'
            },50);
            $(this).next(1).stop().animate({
                width:'60px',
                height:'60px'
            },50);
        })
        
        $("ul li").mouseout(function(){
            $(this).stop().animate({
                width:'50px',
                height:'50px'
            },20);
            $(this).prev(1).stop().animate({
                width:'50px',
                height:'50px'
            },20);
            $(this).next(1).stop().animate({
                width:'50px',
                height:'50px'
            },20);
        })
    </script>

图片地址:

https://github.com/skyflyscroll/mouseImg.git

耗费精力+脑力两个晚上,实验了Tweenjs、tween.js、以及animation库,还是有好多bug,难以控制,小果最后选择了设定确定值进行动画。动画效果远远不及源页面动画的平滑度和既视感~~~~(>_<)~~~~

源网址:

http://www.linqing07.com/cheats.html#id=5

效果块:

希望各路大神指点迷津,带我飞!O(∩_∩)O

欢迎和小果交流,谢谢阅读。

 

转载于:https://www.cnblogs.com/mihoutaoguniang/p/6018617.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值