CSS and conditional statements
I was playing around with a few ideas for a site redesign a while ago. I wanted a pretty sort of "heading" thing for the site, but decided that instead of using an image I'd be a good, accessibility-aware, standards-compliant guy and do it all with CSS. Fine. Stick in a couple of DIVs, set the background colours and you're done. At least I thought it would be easy - Firefox (and so I assume all/most Gecko based things) seems to whack on a huge extra margin at the bottom of the DIVs.So anyway I didn't realise this at this stage - stuck in all of the HTML and CSS, chose my colours I was going to use, padded the page out with some lorem ipsum and double clicked the html file, which loaded it up in Internet Explorer 6 (this is the default action for my Windows setup - I usually browse with firefox). This is what it looked like (although I've added in a dashed border around the problem area for clarity).
margin-bottom : -40px;
<!--[if IE]>
margin-bottom : 0px;
<![endif]-->
So now, Firefox (and everything else for that matter - cant be bothered to check the rendering with Opera and I dont have access to Safari but thats Gecko anyway) will use -40px for its margin-bottom, but IE will use the 0px value. Tried it again and now everything looks as it should in both browsers - a very handy little CSS hack I am sure you'll agree! I'm not sure how widely this is supported, but I'm assuming that the huge majority of users are using IE5 or 6, or something like Firefox or some other Gecko browser so I'm happy.
If anyone has a proper solution to this, I'd love to hear it! Feel free to get in touch!
Back
23.02.2006.
Opps, problem left after from porting the article from the previous CMS. Fixed now. Thanks for letting me know!
Matt
06.06.2006
Did you also know that you can do conditional if statements to select specific versions of Internet Exlorer?
Oliver
09.06.2007
Uh... are you missing some code? I see the "end if", but not the "if" or the "else"