调整滚动条偏移量?
有没有办法防止垂直滚动条压过您的内容?
我有一个页面,它根据不同的输入更改高度,并且每次切换输入时滚动条都会来回推动我的内容(内容居中)。
我尝试用 css 和一点 jquery 来调整它,但似乎没有效果。我不想隐藏滚动条或使其始终可见。
似乎可以使用 javascript 或 jquery 来调整。这是 jsFiddle ,这是我的代码:
<center>
<div id="content-container">
<div id="img" style="left: 50%; position:fixed">
<img src="http://www.google.com/images/logos/ps_logo2.png" width="122">
</div>
<div id="panel" style="position:absolute;top:1950px; border:solid; widt:00px; ">
<div class="content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div><!-- Panel -->
</div><!-- content -->
</div><!-- content-container -->
</center>
<script>
// On load panel slides in from bottom of page
$("#panel").delay(100).animate({
top: "150px"
}, 1000);
</script>
我想也许解决方案是使用 Javascript 滚动偏移 但我不确定。
Is there a way to prevent the vertical scrollbar from pushing over your content?
I have a page that changes height based on different inputs and the scrollbar pushes my content back and forth each time an input is toggled (content is centered).
Ive tried adjusting this with css and a little jquery but seems to have no effect. I dont want to hide the scrollbars or make it so the scrollbars are always visible.
seems that this could be adjusted using javascript or jquery. Heres a jsFiddle and heres my code:
<center>
<div id="content-container">
<div id="img" style="left: 50%; position:fixed">
<img src="http://www.google.com/images/logos/ps_logo2.png" width="122">
</div>
<div id="panel" style="position:absolute;top:1950px; border:solid; widt:00px; ">
<div class="content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div><!-- Panel -->
</div><!-- content -->
</div><!-- content-container -->
</center>
<script>
// On load panel slides in from bottom of page
$("#panel").delay(100).animate({
top: "150px"
}, 1000);
</script>
I thought maybe the solution was to use Javascript scroll offset but am unsure.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
overflow:scroll
添加到 body 元素的样式中。这将强制浏览器显示滚动条,无论内容是否溢出。Add
overflow:scroll
to the style of the body element. This will force the browser to display scrollbars whether the content overflows or not.