-moz-scrollbars-vertical 相当于 Chrome/Opera/Safari?

发布于 2024-08-12 03:08:44 字数 243 浏览 3 评论 0原文

IE6、IE7 和 IE8 默认情况下显示页面的垂直滚动条,即使它不可滚动。 Chrome 和 Firefox 不会这样做(我假设 Opera 和 Safari 也不会这样做)。您可以使用 CSS 在 FireFox 中完成相同的行为:

body { overflow: -moz-scrollbars-vertical; }

有没有办法在其他三个浏览器中强制显示滚动条?或者更好的是,有一个标准的方法?

IE6, IE7, and IE8 display a vertical scroll bar for the page by default even if it is not scrollable. Chrome and Firefox do not do this (I'm assuming Opera and Safari do not as well). You can accomplish this same behavior in FireFox using the CSS:

body { overflow: -moz-scrollbars-vertical; }

Is there any way to force the visible scrollbar in the other three browsers? Or even better, a standard way of doing it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

踏月而来 2024-08-19 03:08:44

更新

您可能(此外)需要包含 -ms-overflow-y 和/或 -moz-scrollbars-vertical,如 此其他 StackOverflow 帖子

html {
    overflow: -moz-scrollbars-vertical; /* For FF */
    -ms-overflow-y: scroll; /* For IE */
    overflow-y: scroll; /* For others & old IE */
}

原文

html { overflow-y: scroll; }

参见 W3Schools 的“overflow-y”

已测试已在以下位置验证(成功):

  • FF 7
  • Chrome 15
  • IE 5+6+7+8+9+10(平台预览)w/IETester
  • Opera 11.52
  • Safari/Win 5.1.1

完整示例

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
    html { overflow-y: scroll; }
</style>
</head>
<body>
    Test content
</body>
</html>

Update

You may (in addition) need to include -ms-overflow-y and/or -moz-scrollbars-vertical, as mentioned in this other StackOverflow post:

html {
    overflow: -moz-scrollbars-vertical; /* For FF */
    -ms-overflow-y: scroll; /* For IE */
    overflow-y: scroll; /* For others & old IE */
}

Original

html { overflow-y: scroll; }

See "overflow-y" at W3Schools

Tested & verified (successfully) in:

  • FF 7
  • Chrome 15
  • IE 5+6+7+8+9+10(platform preview) w/IETester
  • Opera 11.52
  • Safari/Win 5.1.1

Full example

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
    html { overflow-y: scroll; }
</style>
</head>
<body>
    Test content
</body>
</html>
Oo萌小芽oO 2024-08-19 03:08:44
html { height: 100%; margin-bottom: 1px; }

有关更多信息,请参阅强制滚动条(现在更好)信息。

html { height: 100%; margin-bottom: 1px; }

See Forcing scrollbars (now even better) for more information.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文