css3实现滚动手表
静态html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style>
@charset "utf-8";
body,div,h1,p,hr{margin: 0;padding: 0;}
body{font-family: "微软雅黑";}
.continer,body,html{height: 100%;}
.continer>div{box-sizing: border-box;}
/*.continer img{display: block;}*/
.top{height: 10%;border-bottom: 1px solid #ccc;}
.left{height: 90%;width: 18%;float: left;border-right: 1px solid #ccc;}
.left img{height: 180px;width: 120px;margin: 20px auto 0;cursor: pointer;display: block;}
.right{height: 90%;width: 80%;float: right;}
.right img{height: 550px;margin: 50px auto;display: block;}
</style>
<script type="text/javascript" src="js/jquery-1.11.2.min.js" ></script>
</head>
<body>
<div class="container">
<div class="top">
<h1>Apple Watch</h1>
<p>手表手表</p>
</div>
<div class="left">
<img src="img/watch1.jpg" />
<img src="img/watch2.jpg" />
<img src="img/watch3.jpg" />
</div>
<div class="right">
<img src="img/watch1.jpg" />
<img src="img/watch2.jpg" />
<img src="img/watch3.jpg" />
</div>
</div>
</body>
</html>
jq代码:
$(function(){
//右侧div中除了第一张图片,其他都隐藏;
$(".right>img:not(:first)").hide();
//点击左侧小图标
$(".left>img").mouseover(function(){
//获取小图下标
var index=$(this).index();
//根据下标找到对应的大图
var bigPic=$(".right>img").eq(index);
//让当前大图显示,其他大图隐藏
bigPic.stop().slideDown(700).siblings().stop().slideUp(700);
})
})