I want to have a form which consists of different input fields. On some rows there should be two input fields. The second one should be aligned right.
HTML:
<table>
<tr>
<td>
<input type="text" name="first-name" class="form-first-name" />
<input type="text" name="last-name" class="form-last-name" />
</td>
</tr>
<tr>
<td class="empty-row"> </td>
</tr>
<tr>
<td>
<input type="text" name="address-1" class="form-address-1" />
</td>
</tr>
</table>
CSS:
.form-address-1 {
width: 100%;
}
.form-first-name, .form-last-name {
width: 46%;
}
.form-last-name {
float: right;
}
My problem is that the input fields have different sizes and so the size of the row somehow changes. I tried to set the width of tr
without success. How can I align the second input field right?
Its a box-layout issue.
check with the inspector, and you'll see that your address input is overflowing its row. (thats because 100% + default margin/padding = more than 100%)
Add this to your CSS
*
{
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}