Does the “overflow-y: scroll” property help preven

2019-05-10 19:47发布

问题:

I'm using the following in my CSS to force a vertical scrollbar in Firefox:

body {
  overflow-y: scroll;
}

Does this technique work in Safari and Opera? Some people say it does and some say otherwise.

回答1:

The CSS rule overflow-y: scroll works for me in:

  • Opera 10.10
  • Google Chrome 3.0.195.38
  • Mozilla Firefox 3.5.6

and obviously all versions of Microsoft Internet Explorer where the scrollbar is always shown.

Safari and Google Chrome are using the same view engine, so chances are it works in Safari as well :)



回答2:

This:

body {
  overflow-y: scroll;
}

works in Opera 11.01 and Safari 5.0.3 for Windows, but this:

html {
  overflow-y: scroll;
}

doesn't work in Opera and works for the rest.