css已经写好在非ie浏览器下可以实现跟随滚动
#roll{
display:block;
width:15px;
margin-right:466px;
margin-top:93px;
position:fixed;
right:50%;
top:162px;
_margin-right:382px;
_position:absolute;
_margin-top:252px;
_top:expression(eval(document.documentElement.scrollTop));
}
#roll{
display:block;
width:15px;
margin-right:466px;
margin-top:93px;
position:fixed;
right:50%;
top:162px;
_margin-right:382px;
_position:absolute;
_margin-top:252px;
_top:expression(eval(document.documentElement.scrollTop));
}
所以要用JS判断 我不知道怎么用单纯CSS实现
var $scroll = $("#scroll"), //scroll为跟随滚动条移动的dom id
$window = $(window),
offset = $scroll.offset(),
topPadding = 250; //距离顶部距离的大小,自己调整
$window.scroll(function () {
if ($window.scrollTop() > offset.top) {
$scroll.stop().animate({
marginTop: $window.scrollTop() - offset.top + topPadding
});
} else {
$scroll.stop().animate({
marginTop: 0
});
}
});
});不知道你是不是想要这种效果。