I have set the width of a container div to be 100%, and for some reason any other elements placed within that container with a width of 100% (of that container div, i.e. 100% screen width) exceed the width of the screen and cause a horizontal scrollbar to appear at the bottom of the browser.
Any ideas on why this is happening and how to fix it would be much appreciated.
Now with this CSS, for some reason the masthead extends past the edge of the screen and a horizontal scrollbar is provided at the bottom of the browser window. I’m afraid I can’t offer the CSS in context due to my employer, but I don’t think any other markup or CSS around this code should be affecting it.
With the code I have submitted, a scroll bar does appear. I have tried putting margin: 0; padding: 0; in the #masthead rule, but that didn’t have any effect. However, I didn’t think this would be the issue, as the rule I have defined for the body element already had margin: 0; and padding: 0;
I think it’s probably just a conflict of rules somewhere, I’ll keep at it until I get rid of that pesky scrollbar.
As I said before, I would post more CSS and markup, but I work for a public sector organisation and don’t think I should post too much material. Besides, the total markup and CSS is quite sizeable.
I found my problem. There was a #topnav div nested beneath the p#masthead causing the problem. It had a width of 100%, but also a padding-left: 120px (to line up with something in the masthead). This padding was obviously adding to the 100% width. Clearly I can’t rectify this by using an expression such as ‘100% - 120px’ so I found that adding a margin-right: 120px fixed the problem.
This is a bit sloppy I know; is there a better way to do this? I usually design standards compliant for FF and then tweak for IE, but since my organisation uses IE exclusively for the Intranet then FF compatibility isn’t an issue.