I need to position labels controls, exactly one underneath the other and sometimes to the side. I do this with a table, but I ask. Is there another way to do this and give a result similar to table? Table is legible, and everything mine is dynamic.
I need to position labels controls, exactly one underneath the other and sometimes to the side. I do this with a table, but I ask. Is there another way to do this and give a result similar to table? Table is legible, and everything mine is dynamic.
Why escape the tables? They are there to be used (just will not use them to position layout, please). Anyway, of course there is.
Consider the following HTML:
<form action="">
<fieldset>
<legend>Nosso form</legend>
<label><span>Nome:</span>
<input type="text" size="25" /></label>
<label><span>Idade:</span>
<input type="text" size="25" /></label>
<label><span>Besteiras:</span>
<textarea rows="10" cols="23"></textarea></label>
<label><span>Nome de novo:</span>
<input type="text" size="25" /></label>
<div><input type="submit" class="submit"
name="submit" value="Enviar" /></div>
</fieldset>
</form>
Here's our first example:
fieldset span { float: left; width: 6em; text-align: right; }
label { display: block; margin: 0; padding: 0;}
input, textarea { text-align: left; }
input.submit { text-align: center; }
Second example, only more elegant:
fieldset span { float: left; width: 6em; text-align: right; }
label { display: block; margin: 0; padding: 0;}
input, textarea { text-align: left; }
input.submit { text-align: center; }
body { font-size: 80%; }
label, input.submit, legend, fieldset { font: normal 1em
Verdana, Geneva, Arial, Helvetica, sans-serif; }
legend { padding: 1em; }
label { margin: 0.5em; }
fieldset { padding: 1em; }
fieldset div { margin: 0.5em; padding-left: 6.5em; }
fieldset span { padding-right: 0.5em; }