Click here to get back home

margins on cleared floats in Opera

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
margins on cleared floats in Opera listerofsmeg01 11-05-2006
Posted by listerofsmeg01 on November 5, 2006, 11:34 am
Please log in for more thread options


Argh! I'm going nuts trying to get a constant margin after a floated
div that works cross browser.

This works in IE but not Firefox:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head></head>
<body>
<div style="float:left; height:100px; background-color:red;">Hi,
I'm floating</div>
<div style="clear:both; margin-top:50px;">This text should have a
margin after the floated div</div>
</body>
</html>

This works in both IE and firefox, but not Opera

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head></head>
<body>
<div style="float:left; height:100px; background-color:red;">Hi,
I'm floating</div>
<div style="clear:both;"></div>
<div style="margin-top:50px;">This text should have a margin after
the floated div</div>
</body>
</html>

It appears Opera only honours the clearing div for margins if it
contains something. However, if it contains something, then I get extra
whitespace which I can't seem to get rid of. ie:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head></head>
<body>
<div style="float:left; height:100px; background-color:red;">Hi,
I'm floating</div>
<div style="clear:both; margin:0; border:0;
padding:0;">&nbsp;</div>
<div style="margin-top:50px;">This text should have a margin after
the floated div</div>
</body>
</html>

This appears to work fine, until you make the margin smaller - say 2
pixels:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head></head>
<body>
<div style="float:left; height:100px; background-color:red;">Hi,
I'm floating</div>
<div style="clear:both; margin:0; border:0;
padding:0;">&nbsp;</div>
<div style="margin-top:2px;">This text should have a margin after
the floated div</div>
</body>
</html>

Where's the sodding whitespace coming from! Argh!

Many thanks for any help


Posted by listerofsmeg01 on November 5, 2006, 11:37 am
Please log in for more thread options



listerofsme...@hotmail.com wrote:
> Argh! I'm going nuts trying to get a constant margin after a floated
> div that works cross browser.
>
> This works in IE but not Firefox:
>
> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
> <head></head>
> <body>
> <div style="float:left; height:100px; background-color:red;">Hi,
> I'm floating</div>
> <div style="clear:both; margin-top:50px;">This text should have a
> margin after the floated div</div>
> </body>
> </html>
>
> This works in both IE and firefox, but not Opera
>
> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
> <head></head>
> <body>
> <div style="float:left; height:100px; background-color:red;">Hi,
> I'm floating</div>
> <div style="clear:both;"></div>
> <div style="margin-top:50px;">This text should have a margin after
> the floated div</div>
> </body>
> </html>
>
> It appears Opera only honours the clearing div for margins if it
> contains something. However, if it contains something, then I get extra
> whitespace which I can't seem to get rid of. ie:
>
> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
> <head></head>
> <body>
> <div style="float:left; height:100px; background-color:red;">Hi,
> I'm floating</div>
> <div style="clear:both; margin:0; border:0;
> padding:0;">&nbsp;</div>
> <div style="margin-top:50px;">This text should have a margin after
> the floated div</div>
> </body>
> </html>
>
> This appears to work fine, until you make the margin smaller - say 2
> pixels:
>
> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
> <head></head>
> <body>
> <div style="float:left; height:100px; background-color:red;">Hi,
> I'm floating</div>
> <div style="clear:both; margin:0; border:0;
> padding:0;">&nbsp;</div>
> <div style="margin-top:2px;">This text should have a margin after
> the floated div</div>
> </body>
> </html>
>
> Where's the sodding whitespace coming from! Argh!
>
> Many thanks for any help

I should add that the bottom 2 examples have a non breaking whitespace
in the clearing div, but this has disappeared from my post (I guess it
got translated by my browser!)


Posted by Bergamot on November 5, 2006, 12:55 pm
Please log in for more thread options


listerofsmeg01@hotmail.com wrote:
>
> I should add that the bottom 2 examples have a non breaking whitespace
> in the clearing div, but this has disappeared from my post (I guess it
> got translated by my browser!)

Which is one reason why you should always post a URL, not code.

--
Berg

Posted by VK on November 5, 2006, 1:16 pm
Please log in for more thread options


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html401/strict.dtd">
<html>
<head>
<title>KISS</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
</head>
<body>
<div style="float:left; height:100px; background-color:red;">Hi,
I'm floating</div>
<br style="clear:both">
<div style="margin-top:50px;">This text should have a margin after
the floated div</div>
</body>
</html>

See also <http://en.wikipedia.org/wiki/KISS_principle> ;-)


Posted by listerofsmeg01 on November 5, 2006, 3:32 pm
Please log in for more thread options



VK wrote:
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
> "http://www.w3.org/TR/html401/strict.dtd">
> <html>
> <head>
> <title>KISS</title>
> <meta http-equiv="Content-Type"
> content="text/html; charset=iso-8859-1">
> </head>
> <body>
> <div style="float:left; height:100px; background-color:red;">Hi,
> I'm floating</div>
> <br style="clear:both">
> <div style="margin-top:50px;">This text should have a margin after
> the floated div</div>
> </body>
> </html>
>
> See also <http://en.wikipedia.org/wiki/KISS_principle> ;-)

So what's the simple way then?


Similar ThreadsPosted
CSS Floats Images and IE (Help please!) September 4, 2005, 6:55 am
clearing only local floats November 11, 2006, 11:22 am
Clearing floats without introducing a new line. How? August 18, 2005, 2:47 pm
Print versions of HTML cut off at margins September 14, 2004, 9:01 am
suppressing margins on
and tags
September 18, 2005, 5:08 pm
Opera bug workaround July 28, 2004, 11:58 am
Opera 9.5 final is here... June 13, 2008, 1:29 pm
Only clean text in Opera, why ? December 23, 2004, 12:48 pm
Mozilla/Opera Scrollbars January 19, 2006, 4:40 pm
opera doesn't reload iframe August 8, 2006, 6:28 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap