我想将id 1
和id 2
放在彼此旁边,<b>
放在input
元素上方的两个div中。
<div>
<div id="1 " style = "float:left; clear:both">
<b style ="color: #444444" >Date</b>
<input class="duedatetextbox" type="text" placeholder="Enter date" tabindex="101">
</div>
<div id="2" style = "float:left; clear:both;padding-left:80px;">
<b style ="color: #444444" >Time</b>
<input class="duedatetextbox" type="text" placeholder="Enter time" tabindex="102">
</div>
</div>
提前谢谢!
答案 0 :(得分:0)
尝试以下
<div >
<div id="1 " style = "float:left;">
<b style ="color: #444444" >Date</b><br>
<input class="duedatetextbox" type="text" placeholder="Enter date" tabindex="101">
</div>
<div id="2" style = "float:left;padding-left:80px;">
<b style ="color: #444444" >Time</b><br>
<input class="duedatetextbox" type="text" placeholder="Enter time" tabindex="102">
</div>
</div>
答案 1 :(得分:0)
两个div的宽度均为50%,以使它们在宽度上展开,并将b
和input
标记设为display:block
以逐一进行。
div.ids {
width: 50%;
}
div.ids b {
display: block;
padding: 10px;
}
div.ids input {
display: block;
padding: 10px;
background: whitesmoke;
border: solid 1px grey;
border-radius: 3px;
}
<div>
<div class="ids" id="1" style="float:left; clear:both">
<b style="color: #444444">Date</b>
<input class="duedatetextbox" type="text" placeholder="Enter date" tabindex="101">
</div>
<div class="ids" id="2" style="float:left;">
<b style="color: #444444">Time</b>
<input class="duedatetextbox" type="text" placeholder="Enter time" tabindex="102">
</div>
</div>
答案 2 :(得分:0)
将display:flex
和width
添加到主div
<div style="width:400px; display: inline-flex;">
<div id="1 " style = "float:left; clear:both; width:50%;">
<b style ="color: #444444" >Date</b>
<input class="duedatetextbox" type="text" placeholder="Enter date" tabindex="101">
</div>
<div id="2" style = "float:left; clear:both;padding-left:10px; width:50%;">
<b style ="color: #444444" >Time</b>
<input class="duedatetextbox" type="text" placeholder="Enter time" tabindex="102">
</div>
</div>
&#13;