I show text inputs next to the label text in a set of fields. I would like the source text of the text in the text inputs to match the base text of the label. I can set the tudge coefficient padding-topfor my .labelelements, but the contents of my elements .valuemay contain read-only text, and this will align the label / value alignment for these fields. I also suspect that different browsers will require different fudge coefficients due to differences in height between input fields in browsers.
Does anyone have any ideas how I can get the alignment of my labels and sources? My label text can span multiple lines, and so I would like any solution to take this into account.
You can see a live example of the following code at http://jsbin.com/enobe3 .
CSS
* {
font-family: sans-serif;
font-size: 13px;
}
.field {
clear: left;
padding-top: 5px;
}
.label {
float: left;
width: 90px;
}
.value {
margin-left: 90px;
padding-left: 10px;
}
HTML
<fieldset>
<div class="field">
<div class="label">A short label</div>
<div class="value">Some text</div>
</div>
<div class="field">
<div class="label">A long long long long long long long wrapping label</div>
<div class="value">Some text</div>
</div>
<div class="field">
<div class="label">A short label</div>
<div class="value"><input value="Some text"/></div>
</div>
<div class="field">
<div class="label">A long long long long long long long wrapping label</div>
<div class="value"><input value="Some text"/></div>
</div>
</fieldset>
source
share