Jump to content

Why does this CSS code work?


adamcannon

Recommended Posts

I have three tables that are positioned (relative) 25px from each other.  The code below works fine for this purpose but I'm not sure why.  Precisely, why is div.right set to 50px instead of 25px?

 

div.left
{
clear:left;
float:left;
}

div.center
{
float:left;
position:relative;
left:25px;
}

div.right
{
float:left;
position:relative;
left:50px;
}

Link to comment
https://forums.phpfreaks.com/topic/50891-why-does-this-css-code-work/
Share on other sites

You can also remove the "position:relative" elements and that first "clear:left".

 

If you are placing these divs in order, then they are already "relative".

 

The clear:left is then negated by the next command of float:left.

 

That's as if I used,

 

.widths {

width:300px;

width:500px

}

 

The last command always replaces the previous.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.