I've been struggling to get CSS floating to work (in my head).
Note the following example:
<style type="text/css">
div.container {
width:500px;
}
div.left {
float:left;
clear:left;
}
div.right {
float:right;
}
</style>
<div class="container">
<div class="left">leftdata 1</div>
<div class="left">leftdata 2</div>
<div class="right">rightdata 1</div>
<div class="right">rightdata 2</div>
<div class="right">rightdata 3</div>
<div class="right">rightdata 4</div>
</div>
This will give the following output:
+--------------------------------------------------------------------+ | leftdata 1 | | leftdata 2 rightdata 1 rightdata 2 rightdata 3 rightdata 4 | | | +--------------------------------------------------------------------+
However I was expecting this:
+--------------------------------------------------------------------+ | leftdata 1 rightdata 1 rightdata 2 rightdata 3 rightdata 4 | | leftdata 2 | | | +--------------------------------------------------------------------+
Why is clear:left; also clearing right?
My goal:
I want to only add a clear:right; to the DIVs marked with class: right. This should produce the following:
<style type="text/css">
div.left {float:left;clear:left;}
div.right {float:right;clear:right;}
</style>
+--------------------------------------------------------------------+ | leftdata 1 rightdata 1 | | leftdata 2 rightdata 2 | | rightdata 3 | | rightdata 4 | +--------------------------------------------------------------------+