当用户在页面上的任何位置滚动时,是否可以使用jQuery来模拟元素的滚动?我有一个100%高度的div,并使用overflow: scroll
来显示滚动条。页面正文没有滚动条,因为它的高度也是100%。我想这样做,当用户试图滚动页面上的任何地方时,div滚动。这可能吗?
谢谢!
答案 0 :(得分:2)
++++++++++++++++++++++++++++++++++++
+ + + +
+ + + +
+ Left + Content + Right +
+ + + +
+ + + +
++++++++++++++++++++++++++++++++++++
考虑您要滚动内容,而不是左右面板。您可以使用位置:固定为左右面板。
所以无论何时你将滚动页面,它都只会滚动内容面板,而不是滚动内容面板。右边的面板,因为它们是固定的。
<html>
<head>
<style>
html,body,div
{
padding:0px;
margin:0px;
}
#left_panel, #right_panel
{
width:19%;
display:inline-block;
background-color:#22435D;
height:50%;
position:fixed;
}
#center_panel
{
margin-left:20%;
width:60%;
display:inline-block;
height:150%;
background-color:white;
color:#22435D;
border:1px solid #22435D;
}
</style>
</head>
<body>
<div id="left_panel">
</div>
<div id="center_panel">
you content goes here
<br/>
you content goes here
<br/>
you content goes here
<br/>
you content goes here
<br/>
you content goes here
<br/>
you content goes here
<br/>
you content goes here
<br/>
you content goes here
</div>
<div id="right_panel">
</div>
</body>
</html>
现在,如果您滚动页面,它将仅滚动中心面板。