我的问题类似于这篇文章,除了我仍然无法将输入文本显示为内联块 - > inline-block overflowing outside container
我想要5个输入文本,我想将它们包装成:
"项目1"
"项目2" "项目3"
"项目4" "项目5"
我的HTML:
<div class="form">
<div id="inputs">
<label> Email </label>
<div>
<input type="text" [(ngModel)]="email" maxlength="100">
</div>
<label> Address </label>
<div>
<input type="text" [(ngModel)]="address" maxlength="50">
</div>
.....
</div>
</div>
我的CSS:
#inputs {
display: inline-block;
vertical-align: top;
label {
....
}
div {
width: 100%;
....
}
}
我也尝试过display:table,position:absolute和display:inline-flex。但他们没有达到我的期望。
答案 0 :(得分:0)
你可以这样试试 -
#inputs .frmField{
float: left;
vertical-align: top;
}
#inputs .frmField:nth-child(2), #inputs .frmField:nth-child(4){
clear: both
}
label {
display: block;
}
div {
/*width: 100%;*/
}
&#13;
<div class="form">
<div id="inputs">
<div class="frmField">
<label> Email 1</label>
<input type="text" [(ngModel)]="email" maxlength="100">
</div>
<div class="frmField">
<label> Address 2</label>
<input type="text" [(ngModel)]="address" maxlength="50">
</div>
<div class="frmField">
<label> Address 3</label>
<input type="text" [(ngModel)]="address" maxlength="50">
</div>
<div class="frmField">
<label> Address 4</label>
<input type="text" [(ngModel)]="address" maxlength="50">
</div>
<div class="frmField">
<label> Address 5</label>
<input type="text" [(ngModel)]="address" maxlength="50">
</div>
</div>
</div>
&#13;
答案 1 :(得分:0)
我更喜欢使用table来创建表单
<强>段强>
<h1>A FORM</h1>
<table class="form">
<tbody id="inputs">
<tr>
<td><label> Email </label><td>
<td><input type="text" [(ngModel)]="email" maxlength="100"></td>
</tr>
<tr>
<td><label> Address </label><td>
<td><input type="text" [(ngModel)]="email" maxlength="100"></td>
</tr>
<tr>
<td><label> Address </label><td>
<td><input type="text" [(ngModel)]="email" maxlength="100"></td>
</tr>
<tr>
<td><label> Address </label><td>
<td><input type="text" [(ngModel)]="email" maxlength="100"></td>
</tr>
<tr>
<td><label> Address </label><td>
<td><input type="text" [(ngModel)]="email" maxlength="100"></td>
</tr>
</tbody>
</table>
&#13;