Forum Moderators: not2easy

Message Too Old, No Replies

Darn it, % not working the same in Mozilla-created browsers...

Using div ids and % as widths and spacing

         

Llama

6:07 am on Feb 24, 2004 (gmt 0)

10+ Year Member



I have code similar to this:

<html><style>
body { margin-left: 0 margin-top: 0 }
#left { left: 0 width: 20% }
#content { left: 20% width: 60% }
#right { left: 80% width: 20% }
</style>
<div id="left">LEFT</div><div id="content">MIDDLE<div id="right">RIGHT</div></body>

The only problem is: the divs are overlapping, and really just don't look good at all in Mozilla, and Mozilla Firefox.

Also, they just overlap in one big jumble in the middle top for Netscape 4.

How can I get it to look good?
And how can I get it so that when a browser like Netscape 4 comes on, it can just go to a plain text version without the requirement of Javascript?

Thanks beforehand for any provided help :)

Hester

9:12 am on Feb 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try adding
padding:0; margin:0;
to the divs. Do the same for the body and html tags.

SuzyUK

9:25 am on Feb 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



according to the spec
[w3.org...]

top ¦ right ¦ bottom ¦ left

the percentage value refers to the height of the containing block

Try floating the boxes left and giving them widths instead, although be aware that percentage widths will cause rounding differences at different resolutions... (can't be part of a pixel).. so it's quite hard to accurately predict the width unless you're working inside a fixed width container..

Hester

9:41 am on Feb 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



But he did give them widths?

SuzyUK

11:24 am on Feb 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try floating the boxes left and giving them widths instead,..

ok ok ;)

wrong emphasis on sentence - it's the float that should be the "instead" i.e. instead of positioning with top, left etc..... but I also meant to say they will still need widths and to be aware that percentage widths will/could cause rounding errors

read:

Try floating the boxes left instead, you will still need widths on floats, although.....

bumpaw

2:13 pm on Feb 24, 2004 (gmt 0)

10+ Year Member



I think this little tutorial on layout without tables will shed some light on the problem.
[w3.org ]