浮动底栏移动时出现抖动
我创建了一个带有浮动栏的页面。问题是,当我移动右侧的滚动条时,浮动的底部栏正在不稳定地移动,尽管它最终位于底部。
我尝试通过删除背景身体图像或删除 container-msg
的 overflow:auto
来修复抖动问题。它有效,但我需要把它们打开。我该怎么做才能让这个动作顺利进行?
HTML 是:
<body style="background:#cfe1ed url(bg.jpg) repeat-x fixed;margin: 0;padding: 0;text-align: center;color: #404040;font-family: Tahoma, Geneva, sans-serif;font-size: 12px;">
<div id="container-msg" style="width: 900px;min-height: 500px;border: 0;overflow:auto;text-align: left;margin: 0 auto 0 auto;background:#FFF;">
<p>h</p>
<p>dfh</p>
<p>h</p>
<p>fg</p>
<p>hf</p>
<p>h</p>
<p>g</p>
<p>dfg</p>
<p>dfh</p>
<p>fg</p>
<p>hfg</p>
<p>h</p>
<p>fgh</p>
<p>fgh</p>
<p>gfh</p>
<p>fh</p>
<p>dg</p>
<p>h</p>
<p>dfh</p>
<p>h</p>
<p>fg</p>
<p>hf</p>
<p>h</p>
<p>g</p>
<p>dfg</p>
<p>dfh</p>
<p>fg</p>
<p>hfg</p>
<p>h</p>
<p>fgh</p>
<p>fgh</p>
<p>gfh</p>
<p>fh</p>
<p>dg</p>
<p>h</p>
<p>dfh</p>
<p>h</p>
<p>fg</p>
<p>hf</p>
<p>h</p>
<p>fghf</p>
<p>h</p>
</div>
<div id="music" style=" background:#CCC;display:block;position:fixed;height:35px;width:500px;bottom:0px;margin-left:auto;margin-right:auto;
">
</div>
</body>
I created a page with a floating bar. The problem is that when I move the scroll bar on the right, the floating bottom bar is moving jerkily although it eventually is at bottom.
I tried to fix the jerky movement by either removing the background body image or removing the overflow:auto
for container-msg
. It works but I need to have those on. What can I do to make this movement smooth?
The HTML is:
<body style="background:#cfe1ed url(bg.jpg) repeat-x fixed;margin: 0;padding: 0;text-align: center;color: #404040;font-family: Tahoma, Geneva, sans-serif;font-size: 12px;">
<div id="container-msg" style="width: 900px;min-height: 500px;border: 0;overflow:auto;text-align: left;margin: 0 auto 0 auto;background:#FFF;">
<p>h</p>
<p>dfh</p>
<p>h</p>
<p>fg</p>
<p>hf</p>
<p>h</p>
<p>g</p>
<p>dfg</p>
<p>dfh</p>
<p>fg</p>
<p>hfg</p>
<p>h</p>
<p>fgh</p>
<p>fgh</p>
<p>gfh</p>
<p>fh</p>
<p>dg</p>
<p>h</p>
<p>dfh</p>
<p>h</p>
<p>fg</p>
<p>hf</p>
<p>h</p>
<p>g</p>
<p>dfg</p>
<p>dfh</p>
<p>fg</p>
<p>hfg</p>
<p>h</p>
<p>fgh</p>
<p>fgh</p>
<p>gfh</p>
<p>fh</p>
<p>dg</p>
<p>h</p>
<p>dfh</p>
<p>h</p>
<p>fg</p>
<p>hf</p>
<p>h</p>
<p>fghf</p>
<p>h</p>
</div>
<div id="music" style=" background:#CCC;display:block;position:fixed;height:35px;width:500px;bottom:0px;margin-left:auto;margin-right:auto;
">
</div>
</body>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它似乎工作得很好。但是,请确保添加有效的文档类型,否则position:fixed 将无法在 IE7 中工作。对于 IE6,您每次都必须编写一小段 JavaScript 代码来将其向下移动。
It appears to be working perfectly fine. However, make sure you add a VALID doctype else position:fixed will NOT work in IE7. For IE6, you will have to write a small javascript code to move it down each and every time.