jquery实现图片列表鼠标移入微动

所属分类: 网络编程 / JavaScript 阅读数: 215
收藏 0 赞 0 分享

本效果使用jQuery和CSS实现了图片列表,当鼠标移入时图片向左微动,移出则复原。

其中的jQuery事件使用mouseenter 和 mouseleave ,事件绑定方法使用新推荐的on方法。

代码如下:

<!DOCTYPE html>
<html>
<head><meta name="viewport" content="width=device-width, initial-scale=1" />
 <title>jQuery实现图片列表鼠标移入微动_何问起</title><base target="_blank" />
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 <style type="text/css">
 body, div, li, p, img, a {
  margin: 0;
  padding: 0;
 }
 .hovertreecontainer {
  width: 370px;
  margin: 50px auto;
 }
  .hovertreecontainer a {
  text-decoration: none;
  }
 .hovertree-item-box {
  height: 120px;
  width: 185px;
  position: relative;
  padding: 10px;
  box-sizing: border-box;
  float: left;
 }
  .hovertree-item-box .title {
  width: 80px;
  height: 100%;
  color: #4998a1;
  font-size: 14px;
  }
  .hovertree-item-box.odd {
  border-bottom: 1px solid #CCC;
  border-right: 1px solid #CCC;
  }
  .hovertree-item-box.even {
  border-bottom: 1px solid #CCC;
  }

  .hovertree-item-box.nobottom {
  border-bottom: none;
  }
  .hovertree-item-box .hovertree-img-box {
  width: 80px;
  height: 80px;
  overflow: hidden;
  position: absolute;
  right: 10px;
  bottom: 5px;
  }
 .hovertree-img-box img {
  width: 100%;
  height: 100%;
 }
 .hovertreecontainer:after {
  content: "";
  display: block;
  clear: both;
 }
 </style>
</head>
<body>
 <div class="hovertreecontainer"><h2>jQuery实现图片列表鼠标移入微动</h2>
 <a href="http://hovertree.com/texiao/css/20/">
  <div class="hovertree-item-box odd">
  <div class="title">春节对联</div>
  <div class="hovertree-img-box"><img src="https://zhanzhang360.qulang.net/imgupload/008954/o9qashmi.gif"></div>
  </div>
 </a>
 <a href="http://hovertree.com/hvtart/bjae/a6w6e2qg.htm">
  <div class="hovertree-item-box even">
  <div class="title">下雨天</div>
  <div class="hovertree-img-box"><img src="https://zhanzhang360.qulang.net/imgupload/008954/f748s0ko.jpg"></div>
  </div>
 </a>
 <a href="http://hovertree.com/h/bjae/0st5ww13.htm">
  <div class="hovertree-item-box odd">
  <div class="title">磨砂玻璃</div>
  <div class="hovertree-img-box"><img src="https://zhanzhang360.qulang.net/imgupload/008954/agagq0or.jpg"></div>
  </div>
 </a>
 <a href="http://hovertree.com/menu/texiao/">
  <div class="hovertree-item-box even">
  <div class="title">网页特效</div>
  <div class="hovertree-img-box"><img src="https://zhanzhang360.qulang.net/imgupload/008954/r51a22uy.gif"></div>
  </div>
 </a>
 <a href="http://hovertree.com/h/bjaf/hwqtjwjs.htm">
  <div class="hovertree-item-box odd nobottom">
  <div class="title">何问起统计文件数</div>
  <div class="hovertree-img-box"><img src="https://zhanzhang360.qulang.net/imgupload/008954/iofopnro.png"></div>
  </div>
 </a>
 <a href="http://hovertree.com/h/bjaf/hovertreeimg.htm">
  <div class="hovertree-item-box even nobottom">
  <div class="title">HovertreeImg</div>
  <div class="hovertree-img-box"><img src="https://zhanzhang360.qulang.net/imgupload/008954/p3t2ldyr.png"></div>
  </div>
 </a>
 <div><a href="http://hovertree.com/h/bjaf/4mv4wgmj.htm">原文</a> <a href="http://hovertree.com">首页</a> <a href="http://hovertree.com/menu/texiao/">特效</a></div>
 </div>
 <script type="text/javascript" src="https://zhanzhang360.qulang.net/imgupload/008954/jquery-1.11.3.min.js"></script>
 <script type="text/javascript">
 $(function () {
  $('.hovertreecontainer .hover'+'tree-item-box').on('mouseenter', function (ev) {
  var oImgBox = $(this).find('.hovertree-img-box');

  $(oImgBox).stop(true).animate({
   right: '20px'
  }, "normal");
  }).on('mouseleave', function (ev) {
  var oImgBox = $(this).find('.hovertree-img-box');
  $(oImgBox).stop(true).animate({
   right: '10px'
  }, "normal");
  });
 });
 </script>
</body>
</html>

以上就是本文的全部内容,希望对大家有所帮助,同时也希望多多支持脚本之家!

更多精彩内容其他人还在看

Canvas实现放射线动画效果

本文主要分享了Canvas实现放射线动画的示例代码。具有很好的参考价值,下面跟着小编一起来看下吧
收藏 0 赞 0 分享

微信小程序 image组件binderror使用例子与js中的onerror区别

这篇文章主要介绍了微信小程序 image组件binderror使用例子与js中的onerror区别的相关资料,需要的朋友可以参考下
收藏 0 赞 0 分享

原生js轮播(仿慕课网)

本文主要分享了原生js实现仿慕课网的轮播效果。具有很好的参考价值,下面跟着小编一起来看下吧
收藏 0 赞 0 分享

Bootstrap table简单使用总结

这篇文章主要为大家总结了Bootstrap table的简单使用方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

微信小程序之MaterialDesign--input组件详解

本篇文章主要介绍了微信小程序之MaterialDesign--input组件详解,具有一定的参考价值,感兴趣的小伙伴们可以参考一下。
收藏 0 赞 0 分享

浅析javaScript中的浅拷贝和深拷贝

本篇文章主要介绍了浅析javaScript中的浅拷贝和深拷贝,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
收藏 0 赞 0 分享

js时间戳和c#时间戳互转方法(推荐)

下面小编就为大家带来一篇js时间戳和c#时间戳互转方法(推荐)。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
收藏 0 赞 0 分享

Bootstrap模态框使用详解

这篇文章主要为大家详细介绍了Bootstrap模态框的使用方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

Jil,高效的json序列化和反序列化库

下面小编就为大家带来一篇Jil,高效的json序列化和反序列化库。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
收藏 0 赞 0 分享

BootStrap实现带关闭按钮功能

这篇文章主要介绍了BootStrap实现带关闭按钮功能,非常不错,具有参考借鉴价值,需要的朋友可以参考下
收藏 0 赞 0 分享
查看更多