Could anybody write the CSS fragment to do this?
<div class="container">
<span class="left">Left</span><span class="right">Right</span>
</div>
Here's the CSS for .container
:
.container {
position:absolute;
bottom:0;
margin: 0 5px 5px 5px;
}
Notice the position is absolute because it is "absolute positionated" on its containing element.
I've alredy tried float:left
/float:right
on the two nested elements but nothing happens.
You need to set a width in order to use
float
. If you want a width of 100% you can set.container { width: 100%; }
or improve your code into something like:Set the elements to block, set a width and float them.
Example: http://jsfiddle.net/LML2e/
float: left
andfloat: right
will work perfectly when you set a (relative or absolute) width for your.container
divDemo
Side note: If you set the
.container
towidth: 100%
you will get ugly scroll bars due to themargin
. Just use themargin
in the.left
and.right
classes. See here.