我的表单设计有问题,如下所示。
<div class="myRegInfoForm">
<form method="POST" action="action_reg.php">
<table>
<tr>
<td>
<label>Name: </label>
</td>
<td>
<input type="text" name="regname" value="" id="regname" required pattern="[A-Za-z_ ]{1,}" title="Only letters allowed."/>
</td>
</tr>
<tr>
<td>
<label>Course applied for: </label>
<label><?php echo $CourseName ?></label>
</table>
</form>
</div>
添加第二个<td>
后,标签和输入文本框之间有一个宽阔的空间元素,我不确定为什么。谁能帮帮我?
.myRegInfoForm {
display:flex;
justify-content:center;
align-items:center;
}
我想要的输出:
最佳答案
将 td
的 text-align
设置为 right
.myRegInfoForm {
display:flex;
justify-content:center;
align-items:center;
}
.myRegInfoForm td{
text-align: right;
}
<div class="myRegInfoForm">
<form method="POST" action="action_reg.php">
<table>
<tr>
<td>
<label>Name: </label>
</td>
<td>
<input type="text" name="regname" value="" id="regname" required pattern="[A-Za-z_ ]{1,}" title="Only letters allowed."/>
</td>
</tr>
<tr>
<td>
<label>Course applied for: </label>
<label><?php echo $CourseName ?></label>
</table>
</form>
</div>
关于php - 表格标签和输入文本框之间的表宽空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39113709/