问题
In our application for UI we are using JSF or Prime faces for that. We would like to hide the scrollbar for our application, but we are struggling to achieve this in Internet Explorer (We are using IE7).
Is there any way to prevent for displaying the scroll bar in Internet explorer?
I tried to put overflow: hidden;
in CSS,but it's not working.
I have tried nearly every node in the DOM and set width
/height
to 100%
, with margin: 0px
, padding: 0px
. Seems to work great in Firefox, but it doesn't work in IE7?
回答1:
In case of anyone still needs a solution, this one worked for me:
.container{
-ms-overflow-style: none;
overflow: auto;
}
This change allows scroll on the container and hides the bars on IE.
Tested on IE 10 && 11.
Reference
回答2:
Hard to say without seeing the code! Saying that, You could try use using the "Extended Attributes" that Microsoft introduced for Internet Explorer.
<body scroll="no">
EDIT:
You could also try setting the overflow property of the html page in CSS like so.
html, body { overflow: hidden; }
回答3:
This CSS works for me both in Chrome and IE 10:
/* Oculta la scroll-bar pero sigue permitiendo hacer scroll con el mouse */
body::-webkit-scrollbar { display: none; }
html, body { -ms-overflow-style: none; overflow: auto; }
回答4:
You may use this code implement it into body --
body { overflow-x:hidden; }
If not by that look into the layout and see if any container have a untoward width of something which is making the layout stretch a bit...
回答5:
Make sure IE is not in compatibility mode before you beat yourself up while trying overflow:hidden;
回答6:
I cannot provide plain CSS solution, but if you use jQuery, it is easy to set the computed width and height to the body this way:
$("body").css({"width": body.width()+"px", "height": body.height()+"px"})
and then
$("body").css({"overflow": "hidden"});
worked also in IE (at least in IE9+). My goal was to make page not scrollable temporarily (when custom dialog with own scrolling capability was shown). And when custom dialog was closed, I reset the body style attribute to its previous state (to remove the computed body width and height).
来源:https://stackoverflow.com/questions/7242385/hide-scrollbar-in-ie