php - 表格标签和输入文本框之间的表宽空间

标签 php jquery html css

我的表单设计有问题,如下所示。

enter image description here

<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;
}

我想要的输出:

enter image description here

最佳答案

tdtext-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/

相关文章:

php - php 中单独线程上的电子邮件

javascript - Spring ResponseEntity & AJAX 错误函数 : can't access response body content

html - 使表格单元格保持相同的宽度

javascript - 根据宽高比更改图像的宽度

javascript - 从 JavaScript 到 PHP 的参数传递

php - 使用ajax加载laravel View

php - 使用 PHP 将转发的 URL 参数保存到 MySQL 数据库

javascript - 我如何取消计时?

jquery - 如何在 Express 路由处理程序中进行 socket.broadcast.emit?

html - 边框样式不适用于 div