I have the following HTML code:
<div>
<p><label>Faculty <input type="text" class = "f"></label></p>
<p><label >Department<input type="text" class = "f"></label></p>
</div>
How can I make textboxes appear one under another without shifting?
You could do it with inline-block
, additional <span>
tags added.
div > p > label > span {
display: inline-block;
width: 90px;
}
<div>
<p>
<label>
<span>Faculty</span>
<input type="text" class="f" />
</label>
</p>
<p>
<label>
<span>Department</span>
<input type="text" class="f" />
</label>
</p>
</div>
Or, the css table way.
div > p > label {
display: table;
table-layout: fixed;
}
div > p > label > span {
display: table-cell;
}
div > p > label > span:first-child {
width: 90px;
}
<div>
<p>
<label>
<span>Faculty</span>
<span><input type="text" class="f" /></span>
</label>
</p>
<p>
<label>
<span>Department</span>
<span><input type="text" class="f" /></span>
</label>
</p>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With