Forum Moderators: not2easy
<div id="parent">
<div id="labels">Labels</div>
<div id="controls">Controls</div>
<p>Labels on the left. Controls on the right.</p>
</div>
#parent {width:400px;}
#labels, #controls {float:left; width:198px; border:1px solid rgba(0,0,0,1);}
#parent p {clear:both;}
you should always declare the width of the floated element
display: inline-block (will fit the elements side by side if and only if there's room)
Don't use ID (# in CSS) unless you're absolutely certain there can never be more than one of a thing. Otherwise use classes.
<div class="parent">
<div class="labels">Labels</div>
<div class="controls">Controls</div>
<p>Labels on the left. Controls on the right.</p>
</div> .parent {width:400px;}
.labels, .controls {float:left; width:198px; border:1px solid rgba(0,0,0,1);}
.parent p {clear:both;} I discovered that IE7 does not understand display: inline-block
It had been so long since I'd done anything on IE7, I'd forgotten this was the case.
I was thinking but of using CSS position attribute - as I thought that is exactly for that purpose - Am I wrong? Can I achieve what you suggested in previous posts with position attribute or I am totally on the wrong path?
<div class="parent">
<div class="labels">Labels</div>
<div class="controls">Controls</div>
<p>Labels on the left. Controls on the right.</p>
</div> .parent {position:relative; width:400px; padding-top:40px;}
.labels, .controls {position:absolute; width:198px; border:1px solid rgba(0,0,0,1);}
.labels {top:0; left:0;}
.controls {top:0; right:0;} <div class="parent">
<div class="labels">Labels</div>
<div class="controls">Controls</div>
<p>Labels on the left. Controls on the right.</p>
</div> .parent {width:400px; height:24px;}
.labels, .controls {position:relative; width:198px; height:24px; border:1px solid rgba(0,0,0,1);}
.controls {margin-top:-26px; margin-left:200px;} Actually, on that last note... I just checked out caniuse and it looks like Flexbox is now fully supported by all desktop browsers (and all mobile browsers except Opera Mini and IE Mobile).
So, it looks like it's time to start upgrading to Flexbox for 2D layouts.
Sadly, I [k]no[w] nothing about Safari.