jquery仿京东商品放大浏览页面


Posted in jQuery onJune 06, 2017

jquery仿京东商品页面

京东页面大家都很熟悉,进入商品页面把鼠标放在图片上旁边会出现一个放大的效果,接下来就带大家看看怎么实现的!!!!

仿京东商品页面css的代码!!!

*{
  margin: 0;
  padding: 0;
}
.da{
  width: 360px;
  height: 418px;
  float: left;
}
.shang{
  width: 350px;
  height: 350px;
  border: 1px solid #ccc;
  margin: 10px 0 10px 10px;
  position: relative;
}
.yin{
  width: 150px;
  height: 150px;
  border: 1px solid #ccc;
  background: rgba(255,255,255,0.3);
  position: absolute;
  top:0;
  left: 0;
  cursor: pointer;
  display: none;
}
.bao{
  width: 362px;
  height: 56px;
}
.tab{
  width: 320px;
  height: 56px;
  margin-left: 10px;
  overflow: hidden;
}
.Ul{
  width: 9999px;
  height: 56px;
}
.Ul li{
  width: 52px;
  height: 52px;
  float: left;
  border: 2px solid #ccc;
  margin-left: 8px;
  list-style: none;
  position:relative;
  text-align:center;
}
.li{
  width: 52px;
  height: 52px;
  border: 2px solid #FF7403;
}
.li img{
  display: block;
  position: absolute;
  top:50%;
  left: 50%;
  margin-top:-26px;
  margin-left:-26px;
}
.zuo{
  display: block;
  width: 12px;
  height: 56px;
  background: url(../img/icon_clubs.gif) no-repeat;
  background-size: 180px 608px;
  background-position: -82px -462px;
  float: left;
  margin-left: 10px;
}
.you{
  display: block;
  width: 12px;
  height: 56px;
  background: url(../img/icon_clubs.gif) no-repeat;
  background-size: 180px 608px;
  background-position: -95px -462px;
  float: right;
  margin-top: -56px;
}
.xia{
  width: 360px;
  height: 418px;
  border: 1px solid #ccc;
  float: left;
  margin: 10px 0 0px 20px;
  overflow: hidden;
  display: none;
}

.lie{
  width: 1329px;
  height: 30px;
  margin-left: 10px;
  margin-top: 20px;
  border-bottom: 2px solid #BE0000;
}
.lie li{
  float: left;
  list-style: none;
  width: 80px;
  height: 28px;
  background: #fff;
  border-radius: 3px;
  border: 0;
  line-height: 30px;
  text-align: center;
  margin-right: 5px;
  border:1px solid #BE0000;
  color: #c30;
  cursor: pointer;
  font-weight: bold;
}
.lie>ul .ll{
  width: 80px;
  height: 30px;
  background: #BE0000;
  border-radius: 3px;
  border: 0;
  line-height: 30px;
  text-align: center;
  color: #fff;
  cursor: pointer;
}
.nie{
  width: 1329px;
  height: 200px;
  margin-left: 10px;
  overflow: hidden;
}
.bao1{
  width: 1329px;
  height: 500px;
}
.up{
  width: 1329px;
  height: 200px; 
}
.up span{
  display: block;
  padding:10px 0 0 10px;
  margin-bottom: 70px;
}
.up p{
  text-align: center;
  margin-top: 5px;
}
.down{
  width: 1329px;
  height: 300px; 
  background: yellow;
}

仿京东商品页面html的代码!!!

<div>
  <div class="da ">
  <div class="shang">
    <img src="img/b1.jpg" height="350" width="350" id="pian">
    <div class="yin"></div>
  </div>
  <div class="bao">
    <span class="zuo"></span>
  
    <div class="tab">
      <ul class="Ul">
        <li>
          <img src="img/b1.jpg" height="52" width="52" />
        </li>
        <li>
          <img src="img/b2.jpg" height="52" width="52" />
        </li>
        <li>
          <img src="img/b3.jpg" height="52" width="52" />
        </li>
        <li>
          <img src="img/b1.jpg" height="52" width="52" />
        </li>
        <li>
          <img src="img/b2.jpg" height="52" width="52" />
        </li>
        <li>
          <img src="img/b3.jpg" height="52" width="52" />
        </li>
        <li>
          <img src="img/b1.jpg" height="52" width="52" />
        </li>
        <li>
          <img src="img/b2.jpg" height="52" width="52" />
        </li>
      </ul>
    </div>
      <span class="you"></span>
    </div>
    <div class="lie ">
      <ul>
        <li class="ll">图文介绍</li>
        <li>评论(1)</li>
      </ul>
    </div>
  
    <div class="nie">
      <div class="bao1">
        <div class="up">
          <span>暂无好评!</span>
          <p>适用浏览器:IE8、360、FireFox、Chrome、Safari、Opera、傲游、搜狗、世界之窗</p>
          <p>来源:师徒课堂</p>
        </div>
        <div class="down">
          <img src="img/11.png" height="300" width="1329" />
        </div>
      </div>
    </div>
  </div>
  <div class="xia">
    <img src="img/b1.jpg" height="600" width="600" id="zhao" />
  </div>
</div>

仿京东商品页面jquery的代码!!!

$(function(){
  var $yin = $(".yin");
  $(".Ul li img").mouseover(function(){
    $(this).parent().addClass("li").siblings().removeClass("li");
    $("#pian").attr("src",$(this).attr("src"));
    $("#zhao").attr("src",$(this).attr("src"));
  }).mouseout(function(){
    $(this).parent().removeClass("li");
  });

  var l = $(".shang").eq(0).offset().left;
  var t = $(".shang").eq(0).offset().top;
  var width1 = $(".yin").outerWidth()/2;
  var height1 = $(".yin").outerHeight()/2;
  var maxL = $(".shang").width() - $yin.outerWidth();
  var maxT = $(".shang").height() - $yin.outerHeight();
  var bili = $("#zhao").width()/$("#pian").width();

  $(".shang").mousemove(function(e){
    var maskL = e.clientX - l - width1,maskT = e.clientY - t - height1;
    if (maskL < 0) { maskL = 0};
    if (maskT < 0) { maskT = 0};
    if (maskL > maxL) {maskL = maxL};
    if (maskT > maxT) {maskT = maxT};

    $yin.css({"left":maskL,"top":maskT});
    $(".xia").show();
    $(".yin").show();
    $("#zhao").css({"margin-left":-maskL*bili,"margin-top":-maskT*bili});


  });
  $(".shang").mouseleave(function(){
    $(".xia").hide();
    $(".yin").hide();
  });

  var marginLeft = 0;
  $(".you").click(function(){
    marginLeft = marginLeft - 64;
    if (marginLeft < -192) {marginLeft = -192};
    $(".tab ul").stop().animate({"margin-left":marginLeft},"fast");
  });

  $(".zuo").click(function(){
    marginLeft = marginLeft + 64;
    if (marginLeft > 0) {marginLeft = 0};
    $(".tab ul").stop().animate({"margin-left":marginLeft},"fast");
  });

  $(".lie li").click(function(){
    var index=$(this).index();
    $(this).addClass("ll").siblings().removeClass("ll");
     $(".bao1>div").eq(index).show().siblings().hide();
  });
});

仿京东商品页面的效果!!!

jquery仿京东商品放大浏览页面

怎么样,当我做出来的时候感觉神清气爽!!!!!

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持三水点靠木。

jQuery 相关文章推荐
jQuery模拟实现天猫购物车动画效果实例代码
May 25 jQuery
jQuery+C#实现参数RSA加密传输功能【附jsencrypt.js下载】
Jun 26 jQuery
jQuery使用ajax_动力节点Java学院整理
Jul 05 jQuery
jQuery实现所有验证通过方可提交的表单验证
Nov 21 jQuery
jQuery实现列表的增加和删除功能
Jun 14 jQuery
详解如何使用webpack打包多页jquery项目
Feb 01 jQuery
jQuery分组选择器简单用法示例
Apr 04 jQuery
jQuery操作attr、prop、val()/text()/html()、class属性
May 23 jQuery
jQuery-Citys省市区三级菜单联动插件使用详解
Jul 26 jQuery
js判断复选框是否选中的方法示例【基于jQuery】
Oct 10 jQuery
jQuery操作动画完整实例分析
Jan 10 jQuery
jQuery实现购物车全功能
Jan 11 jQuery
jquery实现图片放大点击切换
Jun 06 #jQuery
jquery请求servlet实现ajax异步请求的示例
Jun 03 #jQuery
Jquery EasyUI $.Parser
Jun 02 #jQuery
Spring shiro + bootstrap + jquery.validate 实现登录、注册功能
Jun 02 #jQuery
详解如何在 vue 项目里正确地引用 jquery 和 jquery-ui的插件
Jun 01 #jQuery
jQuery实现web页面樱花坠落的特效
Jun 01 #jQuery
jquery网页加载进度条的实现
Jun 01 #jQuery
You might like
PHP读写文件的方法(生成HTML)
2006/11/27 PHP
给初学者的30条PHP最佳实践(荒野无灯)
2011/08/02 PHP
PHP输入流php://input介绍
2012/09/18 PHP
解析htaccess伪静态的规则
2013/06/18 PHP
Yii使用smsto短信接口的函数demo示例
2016/07/13 PHP
ThinkPHP 模板引擎使用详解
2017/05/07 PHP
改进:论坛UBB代码自动插入方式
2006/12/22 Javascript
前端开发必须知道的JS之原型和继承
2010/07/06 Javascript
js判断浏览器类型的方法
2013/08/07 Javascript
多种方法实现JS动态添加事件
2013/11/01 Javascript
IE6下拉框图层问题探讨及解决
2014/01/03 Javascript
对js关键字命名的疑问介绍
2014/04/25 Javascript
JS动画效果打开、关闭层的实现方法
2015/05/09 Javascript
Javascript实现的简单右键菜单类
2015/09/23 Javascript
详解JavaScript中|单竖杠运算符的使用方法
2016/05/23 Javascript
AngularJS Ajax详解及示例代码
2016/08/17 Javascript
jquery点击展示与隐藏更多内容
2016/12/03 Javascript
jQuery简单获取DIV和A标签元素位置的方法
2017/02/07 Javascript
详解如何在vue项目中引入elementUI组件
2018/02/11 Javascript
jQuery pager.js 插件动态分页功能实例分析
2019/08/02 jQuery
vue Element左侧无限级菜单实现
2020/06/10 Javascript
Python线程的两种编程方式
2015/04/14 Python
从Python程序中访问Java类的简单示例
2015/04/20 Python
Scrapy框架CrawlSpiders的介绍以及使用详解
2017/11/29 Python
Pyqt5 关于流式布局和滚动条的综合使用示例代码
2020/03/24 Python
Python logging模块原理解析及应用
2020/08/13 Python
Python使用内置函数setattr设置对象的属性值
2020/10/16 Python
JD Sports比利时官网:英国领先的运动鞋和运动服饰零售商
2018/10/10 全球购物
印尼综合在线预订网站:Tiket.com(机票、酒店、火车、租车和娱乐)
2018/10/11 全球购物
OLEDBConnection和SQLConnection有什么区别
2013/05/31 面试题
工程招投标邀请书
2014/01/30 职场文书
《我要的是葫芦》教学反思
2014/02/23 职场文书
2014年小学教师工作自我评价
2014/09/22 职场文书
2016春季幼儿园小班开学寄语
2015/12/03 职场文书
留学文书中的个人陈述,应该注意哪些问题?
2019/08/23 职场文书
mysql拆分字符串作为查询条件的示例代码
2022/07/07 MySQL