Okay, firstly let me make it very clear that I know very little about CSS. The nuances of layout in CSS fill me with fear, particularly in terms of trying to get all browsers to behave sensibly.
Until recently, I thought that the C# in Depth web site was reasonably sensibly behaved. It’s a simple layout: header at the top, menu on the left, content on the right. Okay, so it would be nice if the menu (which has a different background colour) could always fill the whole viewport on the left hand side, preferrably staying static as well, but that’s apparently tricky. I’m fine with something which works but isn’t quite as nice as I’d like it to be.
However, it seems we have problems in the land of Internet Explorer. IE6 doesn’t render the menu at all, but puts the content several hundred pixels to the right. That’s bad, and I’ve no idea why it’s happening, but I can probably live with it, at least for the moment. IE7 is okay – which made me confident that IE8 would be okay. Not so – beta 2 is causing different oddities.
I’ve set up a page which is pretty minimal but shows the issue. It doesn’t have the header, just a block on the left and a block on the right. It works fine in Chrome, Firefox and IE7. Below are some screenshots of what it looks like under various conditions. I haven’t separated Firefox, IE7 and Chrome as they’re all very similar. Not identical, but close enough. In each case I’ve captured enough of the screen to include the sides of the window, and all the coloured content.
Firefox, Chrome, IE7
Chrome at a normal size, with no wrapping of the text:
Chrome with a narrow window, forcing wrapping:
Initially, IE6 doesn’t show all the content, and none of the left menu.
After making the window wide enough to show all the content on one line (despite odd positioning) the left menu suddenly appears.
Making the window narrow again doesn’t remove the left menu. Weird.
IE8b2 looks okay to start with…
… but when the content doesn’t fit on one line, it displays very oddly. This is the case for all the pages on the C# in Depth site.
Below is the complete source for the page. It’s not exactly complicated.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title>CSS Breakage in IE8b2</title>
<p>Main content div</p>
In IE8b2, if you don't have enough space to get this text on one line, odd stuff happens.
So, am I being dumb? Should this really behave so weirdly on both IE6 and IE8b2? Is it pure coincidence that IE7, Chrome and Firefox (2 and 3, btw) all make the page look how I want it to look?
As I said, I’m really not a CSS guy. I wouldn’t be surprised to find some fundamental flaws in what I’m doing. I’d just like to know how to fix them. And yes, I’ll be asking on a CSS newsgroup when I get the time, probably with a link to this post. Any thoughts welcome.