图片左边点击,右边大图展示

css样式:
*{
margin: 0;
padding: 0;
text-decoration: none;
list-style: none;
}
html,body{
width: 100%;
height: 100%;
}
img{
width: 100%;
height: 100%;
display: block;
}
.left{
width: 30%;
float: left;
background: #ccc;
}
.left > li{
width: calc(100% - 6px);
height: 230px;
float: left;
border: 3px solid #000;
margin: 0 auto 20px;
}
.right{
width: 100%;
margin-top: 0;
}
.right > li{
width: calc(100% - 6px);
height: 600px;
border:3px solid #000;
margin: 0 auto 20px;
}
.srction{
width: 70%;
height: 606px;
float: left;
background: #bbb;
margin-top: 0;
position: fixed;
right: 0;
top: 0;
overflow: hidden;
}

 

html:

<ul class="left" id="left">
<li><img style="background: red;"/></li>
<li><img style="background: blue;"/></li>
<li><img style="background: yellow;"/></li>
<li><img style="background: forestgreen;"/></li>
<li><img style="background: fuchsia;"/></li>
<li><img style="background: green;"/></li>
</ul>
<section class="srction">
<ul class="right" id="right">
<li><img style="background: red;"/></li>
<li><img style="background: blue;"/></li>
<li><img style="background: yellow;"/></li>
<li><img style="background: forestgreen;"/></li>
<li><img style="background: fuchsia;"/></li>
<li><img style="background: green;"/></li>
</ul>
</section>

 

js:

<script type="text/javascript">
window.onload = function(){
var left = document.getElementById('left');
var left_li = left.getElementsByTagName('li');
var len = left_li.length;
var right = document.getElementById('right');
var right_li = right.getElementsByTagName('li');
var num = 0;


function wo(){
right.style.marginTop = '-' + num*626 + 'px';
}

left_li.onclick = function(){
num++;
wo();
}
for(var i=0;i<len;i++){
left_li[i].index = i;
left_li[i].onclick = function(){
num = this.index;
wo()
}
}

}
</script>

转载于:https://www.cnblogs.com/zjhuanjing/p/9073699.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值