What currently happens:
<div title="Oscillator Parameters">
<h3 style="margin-bottom:0px">Oscillator Parameters:</h3>
<label for="oscFreq" style="float:left; display: inline;">Frequency: </label>
<input class="field" id="oscFreq" value="10" style="float:left; width: 4em; margin-right:2px; display: block; clear: left">
<p style="display: inline; float: left; margin-top: 0px" class="units">MHz</p>
<label for="gSense" style="display: inline;clear: none;">G-Sense: </label>
<p style="float: right; margin-bottom: 0px; clear: right;margin-top: 0px;" class="units">MHz</p>
<input class="field" id="gSense" value="10" style="float:right; width: 4em; margin-right: 2px; display: block;">
</div>
With the above code the elements look like this:
Adding float: right;
to the G-sense label makes it look like this (doesn’t work):
What I want to do:
Make the G-sense label, field and units to appear the same as the frequency elements, but the G-sense elements must be on the right side.
How can I move them to the right?
Thanks
3
Answers
Solved by converting the section into a grid and using that instead of float
Make the div
position: relative
and then the<label>
style should beposition:absolute
andright: 0
, maybetop: 0
tooYou can wrap label and input in a p if it has a semantic meaning:
Why does the W3C advise wrapping input elements in <p> tags?