禁用水平滚动条由于DIV与position:absolute在页面之外 [英] Disable horizontal scrollbar due to a DIV with position:absolute which is outside of the page

查看:369
本文介绍了禁用水平滚动条由于DIV与position:absolute在页面之外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个绝对定位的元素是页面外,但我想要浏览器(我使用Firefox 3)不显示水平滚动条。看起来显示位于左侧的div(例如,具有left:-20px)是可以的,并且不显示滚动条。然而,右边的同样的事情(右:-20px)总是显示滚动条。是否可以隐藏滚动条,但是保持标准滚动可能吗?我的意思是我只想禁用滚动由于这个绝对定位的元素,但要保持滚动由于其他元素(我知道我可以完全禁用滚动条,这不是我想要的)。

 <!DOCTYPE html> 
< html>
< body>
< div id =el1style =position:absolute; top:0; background-color:yellow; left:-20px;>
元素
< / div>
< div id =el2style =position:absolute; top:0; background-color:yellow; right:-20px;>
元素
< / div>
< h1> Hello< / h1>
< p> world< / p>
< / body>
< / html>


解决方案

是的,键入 style =overflow-x:hidden。这将会做的...


I have an absolutely positioned element that is "outside" of the page, but I want browsers (I am using Firefox 3) not to display horizontal scrollbars. It seems that displaying a div that is positioned to the left (e.g. having "left: -20px") is okay, and no scrollbar is shown. However the same thing on the right ("right: -20px") always shows the scrollbar. Is it possible to hide the scrollbar, but to keep standard scrolling possible? I mean I only want to disable scrolling due to this absolute-positioned element, but to keep scrolling due to other elements (I know I can disable scrollbars completely, that's not what I want).

<!DOCTYPE html>
<html>
<body>
  <div id="el1" style="position: absolute; top: 0; background-color: yellow; left: -20px;">
    element
  </div>
  <div id="el2" style="position: absolute; top: 0; background-color: yellow; right: -20px;">
    element
  </div>
  <h1>Hello</h1>
  <p>world</p>
</body>
</html>

解决方案

Yes, it is possible, on your html tag, type style="overflow-x: hidden". That'll do the trick...

这篇关于禁用水平滚动条由于DIV与position:absolute在页面之外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆