Forum Moderators: not2easy

Message Too Old, No Replies

Firefox/Opera problem

Website displays fine in IE7, but not in Firefox/Opera

         

tcbigcat

8:00 am on Jun 5, 2009 (gmt 0)

10+ Year Member



Hi, I am a newbie to the world of web development. I've built what I thought was a standards-compliant site (xhtml and css validated fine), but it looks horrid in Firefox (I know, I know - just been reading I should have made it work in Firefox first - I'll know for next time!). It's a 2-column design, white background to the 2 columns so it looks like one big white rectangle, on a dark grey slate background. Looks great in IE7 (tho poo in IE8 - fixed by an additional meta tag), but in Firefox the white background on my right column has broken away, leaving a dark grey band above and to the left, and on my left column seems to have shrunk vertically so it's now shorter than the right. Eek!

Doctype is <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Just been reading that using xhtml is a bad idea - the only reason I use it is because that was how the book I used to teach myself (Headfirst HTML & CSS) taught it! I'm happy to strip out any xhtml and change the doctype if that's causing a problem.

I read an earlier thread from someone with what sounded like a similar problem, and theirs was fixed by changing margins etc in the tables - but I'm not using tables.

Both code and html are W3C standards-compliant, so I don't know where to start looking for the problem.

I've stripped out the content, and the shell of the structure is below. The 'Main' div is the left column, with horizontal nav bar. The 'Sidebar' div is the right column and is just a series of images.

<body>

<div id='wrap'>

<div id="main">

<p>

</p>

<div id="nav">

<ul>
<li </li>
<li </li>
<li </li>
<li </li>
</ul>

</div><!--end div nav-->

<p class="justified">

</p>

<p class="justified">

</p>

<p class="italic">

</p>

<p class="footer">

</p>

</div><!-- end div main -->

<div id="sidebar">

<p>
<img />
<br /><br />

<img />

<img />
</p>

</div><!-- end div sidebar -->

</div> <!-- end div wrap -->

</body>

Here's the CSS relating to the sizing/structure of the page:

#wrap {
width:745px;
padding-top:5px;
padding-bottom:5px;
margin-left:auto;
margin-right:auto;
}

#sidebar {
float:right;
width:260px;
padding:5px;
margin-top:20px;
list-style:none;
border: none;
}

#main {
float:left;
width:430px;
padding:20px;
margin-top:5px;
margin-right:5px;
}

Any helpful hints would be most gratefully received!

Regards,
Tanya

swa66

12:34 pm on Jun 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As long as your code is valid, xhtml will not cause problems (personally: on the contrary as it's more strict in validation as it doesn;t have silent implied closures).

Developed to look great in legacy IE versions: that is a real problem. Most of us do it the other way around as it's easier.

But no despair yet, this is simple enough I think: in a standards compliant browser (read: all but the legacy IE versions such as IE6 and IE7) an element (such as your wrap) will not get stretched cause it has children that are floater (such as your main and sidebar). Only content that is not floated will make it stretch. So the easiest solution is to add something inside the wrap that is not floated and stays below the floats. In the html a simple

<br class="clear" />
and some CSS:
.clear {
clear:both;
}

should do the trick. Another solution is to seach for "clearfix", it's CSS only, but often contains hacks, so be careful you fully understand what it does before going there.

tcbigcat

6:23 pm on Jun 5, 2009 (gmt 0)

10+ Year Member



swa66 - you a God amongst men/Goddess amongst women (delete as appropriate). Your solution worked beautifully! Thank you so much for taking the time to reply.

Kindest regards,
Tanya