寫前端頁面的時候難免遇到表單的樣式自適應,文字+input,文字數量又不確定,表單還要自適應某個div的寬度
<style>
.col{ width: 48%; height: 34px; float: left; }
.label{ float: left; line-height: 34px; text-align: right; width: 90px; }
.input{ margin-left: 90px; }
.input input{ width: 100%; box-sizing: border-box; height: 34px; border: 1px solid #ccc; border-radius: 3px; }
</style>
<div>
<div class="col">
<span class="label">姓名:</span>
<div class="input">
<input type="text">
</div>
</div>
<div class="col">
<span class="label">身份證號碼:</span>
<div class="input">
<input type="text">
</div>
</div>
</div>