更新时间:2021-09-28 22:03:45
如何在右边的列中设置 overflow:auto;
?
What about setting overflow: auto;
to the right column?
.connected.right {
position: fixed;
overflow: auto;
min-height:100px;
height: 200px;
float: right;
}
这将设置滚动到它,并将允许滚动,直到
This will set a scroll to it and will allow scrolling until the very end of the column.
演示: https:// jsfiddle。 net / 8fxosb5f / 2 /
也可以通过设置 overflow:auto
到两列。但是这种方式你需要设置一定高度的那些列。结果可能不是你需要的,仍然是一个演示:
Or you can remove the window scroll by setting overflow: auto
to both columns. But that way you need to set a certain height of those columns. The result might not be what you need, still here's a demo:
https://jsfiddle.net/8fxosb5f/3/
这里有一个非常粗糙的代码,但我认为你会设置为符合你的需求:(它需要jQuery)
Here's a really rough code, but I think you will manage to set it to fit your needs: (it requires jQuery)
var columnHeight = $('.right').outerHeight(true);
var windowHeight = $(window).height();
$(window).scroll(function () {
if ($(this).scrollTop() + windowHeight >= columnHeight) {
$('.right').css({
position: 'fixed',
top: -(columnHeight - windowHeight)
});
} else {
$('.right').css({
position: 'static',
top: 'auto'
});
}
});