您的位置:首页 > Web前端 > JQuery

jQuery实现楼梯

2016-06-07 19:17 495 查看
用jQuery找到文档中的相应的div的top值,在赋值就可以实现楼梯效果了
</pre><pre name="code" class="html" style="color: rgb(43, 126, 195); font-size: 15px;"><!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="js/jquery.js"></script>
<style type="text/css">
#wra div{
width: 1028px;
height: 726px;
text-align: center;
font-size: 100PX;
line-height:726px;
}
#wra #div1{
background: red;
}
#wra #div2{
background: oldlace;
}
#wra #div3{
background: palegreen;
}
#wrap{
width: 100px;
height: 300px;
position: fixed;
left: 1000px;
top: 300px;
background: oldlace;

}
#wrap div{
width:100px ;
height: 100px;
text-align: center;
line-height: 100px;
}
</style>
</head>
<body>
<div id="wra">
<div id="div1">div1</div>
<div id="div2">div2</div>
<div id="div3">div3</div>
<div id="div4">div4</div>
</div>
<div id="wrap">
<div >1</div>
<div >2</div>
<div >3</div>
</div>
</body>
<script type="text/javascript">
$(function(){
$('#wrap div').click(function(){
$(document).scrollTop($('#wra').children().eq($(this).index()).offset().top);
})
})
</script>
</html>

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: