这是一种有效的方法:
form {
width: 80%;
margin: 0 auto;
}
label, input {
/* In order to define widths */
display: inline-block;
}
label {
width: 30%;
/* Positions the label text beside the input */
text-align: right;
}
label + input {
width: 30%;
/* Large margin-right to force the next element to the new-line
and margin-left to create a gutter between the label and input */
margin: 0 30% 0 4%;
}
/* Only the submit button is matched by this selector,
but to be sure you Could use an id or class for that button */
input + input {
float: right;
}
?
调整尺寸和边距以适合您的用例和美观。