Disable Horizontal ScrollBar in IE
Last night, I was working on a template for a new bulletin board software. Well the bulletin board is being developed by my friend. And am taking designing part of it. Let the software and person be forbidden. While designing the homepage, we noticed horizontal scrollbar in IE 6 & 7 @ low resolutions. So he informed me regarding that.
And I thought of using javascript in the beginning, but he argued not to do that, because the reason is simple. Not everyone’s browser will have javascript installed/enabled. So I remembered a small CSS code, which can do the job. Then, we solved the problem.
So, I thought of writing a small tutorial which teaches about disable or removing unwanted horizontal scrollbar in IE6 / IE7 without using any javascripts.
If a theme or a template spans more than 1000px in width, the users who are on 1024 x 768 resolution monitors will see frustrating and unwanted scrollbars in IE 6 & 7.
In order to disable it, there are several methods. Among those javascript is the main, but what if the user do not have javascript installed on his/her browser?
So the best way to get rid of the scrollbar is to add a CSS code, that will disable the scrollbar bars with no issues.
Below is the CSS code, that you will need to add in the stylesheet of your theme or template:
.html, body {
overflow-x: hidden;
}
If you want to embed in the index page, add this beforre </head> :
<style type="text/css"> <!-- .html, body { overflow-x: hidden; } --> </style>
Thats all!
This entry was posted on Friday, July 25th, 2008 at 11:07 am and is filed under Tutorials. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
July 25th, 2008 at 12:03 pm
That’s a good hack. However, if the user actually needs to be able to scroll horizontally due to a small screen size they will not be able to.
I’ve seen some JavaScript somewhere that detects the users screen size, so you could make it so that if the user’s resolution is really small, it ignores the above css.
Or you could just resize the design it so that the horizontal bars don’t appear at 1024 x 768 resolution.
October 1st, 2008 at 4:57 am
thnx Santosh,it works in my IE 6 browser.
but the cons is that some of my CSS didint apply, after applying your code.
is there a way to fix this also??
Plz help.
Or should I rewrite those CSS files, where i am experiencing the bad font size??
thnx again…
October 1st, 2008 at 5:22 am
@prasad, make sure u closed the bracket properly and placed the code in the right format…
October 24th, 2008 at 6:56 pm
That’s an awesome hack, thank you. I had the same problem with a joomla template, but only in IE7. The user has absolutely no need to scroll left to right, so this worked an absolute treat:
.html, body {
overflow-x: hidden;
}
Thanks very much!
Mike