我在 itemsClass 中 wanted prevbutton 和 nextbutton 当滚动总是居中时是固定的...................... ............
<div class="container">
<div class="items">
<div class="prevbutton button"> prev </div>
<div class="nextbutton button"> next </div>
</div>
</div>
//CSS
.container{
border:1px solid green;
text-align:center;
vertical-align:middle;
padding:5px 0px;
}
.items{
border:1px solid red;
height:800px;
position:relative;
width:500px;
margin:0 auto;
}
.prevbutton,.nextbutton{
top:50%;
cursor:pointer;
position:absolute;
background-color:#FF8000;
font-size:25pt;
border:1px solid red;
width:80px;
text-align:center;
}
.prevbutton{left:-88px;}
.nextbutton{right:-88px;}
//jquery
$(window).bind('scroll', function () {
if ($(window).scrollTop() > num) {
$('.button').addClass('fixed');
} else {
$('.button').removeClass('fixed');
}
});
我希望在 itemClass 中滚动时居中 prediv 和 nextdiv
滚动时..我们如何jquery
我想要这种风格,它总是居中的上一个和下一个按钮.... 如何使用 jquery 和 css
参见 jsfiddle http://jsfiddle.net/kisspa/5kE2y/ 参见示例 http://www.waypointarts.com/blog/2013/06/29/fixing-a-side-bar-while-scrolling-until-bottom
最佳答案
add this css it works jquery not needed
.prevbutton,.nextbutton{
top:50%;
cursor:pointer;
position:fixed;
background-color:#FF8000;
font-size:25pt;
border:1px solid red;
width:80px;
text-align:center;
}
.prevbutton{left:0px;}
.nextbutton{right:0px;}
关于jquery - 如何使用 scroll fixed witin parent..我想要滚动但是 nexbutton 和 prevbuton 是固定移动的..如何使用 jquery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24443184/