html,怎么在表单表格里加hr,还是hr不能放在table里面,最后请教造成图一和图二的原因

html,怎么在表单表格里加hr,还是hr不能放在table里面,最后请教造成图一和图二的原因,第1张

<body>
    <h2>表单</h2>
    <hr />
    <form action="">
        <table>
            <tr>
                <td><h3>姓名:</h3></td>
            </tr>
            <tr>
                <td>姓:</td>
                <td><input type="text" name="" /></td>
            </tr>
            <tr>
                <td>名:</td>
                <td><input type="text" name="" /></td>
            </tr>
            <tr>
                <td colspan="2"><hr /></td>
            </tr>
            <tr>
                <td><h3>性别:</h3></td>
            </tr>
            <tr>
                <td><input type="radio" name="sex" />男</td>
            </tr>
            <tr>
                <td><input type="radio" name="sex" />女</td>
            </tr>
            <tr>
                <td colspan="2"><hr /></td>
            </tr>
            <tr>
                <td><h3>班级:</h3></td>
            </tr>
            <tr>
                <td>
                    <select>
                        <option>计科1班</option>
                        <option>计科2班</option>
                        <option>计科3班</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td colspan="2"><hr /></td>
            </tr>
            <tr>
                <td><h3>寝室:</h3></td>
            </tr>
            <tr>
                <td>
                    <select>
                        <option>12</option>
                        <option>13</option>
                        <option>14</option>
                    </select>
                </td>
                <td>舍<input type="text" name=""></td>
            </tr>
        </table>
    </form>
</body><body>
    <h2>表单</h2>
    <hr />
    <form action="">
        <table>
            <tr>
                <td><h3>姓名:</h3></td>
            </tr>
            <tr>
                <td>姓:</td>
                <td><input type="text" name="" /></td>
            </tr>
            <tr>
                <td>名:</td>
                <td><input type="text" name="" /></td>
            </tr>
            <tr>
                <td colspan="2"><hr /></td>
            </tr>
            <tr>
                <td><h3>性别:</h3></td>
            </tr>
            <tr>
                <td><input type="radio" name="sex" />男</td>
            </tr>
            <tr>
                <td><input type="radio" name="sex" />女</td>
            </tr>
            <tr>
                <td><h3>班级:</h3></td>
            </tr>
            <tr>
                <td>
                    <select>
                        <option>计科1班</option>
                        <option>计科2班</option>
                        <option>计科3班</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td><h3>寝室:</h3></td>
            </tr>
            <tr>
                <td>
                    <select>
                        <option>12</option>
                        <option>13</option>
                        <option>14</option>
                    </select>
                </td>
                <td>舍<input type="text" name=""></td>
            </tr>
            <tr>
                <td colspan="2"><hr /></td>
            </tr>
        </table>
    </form>
</body><body>
    <h2>表单</h2>
    <hr />
    <form action="">
        <table>
            <tr>
                <td><h3>姓名:</h3></td>
            </tr>
            <tr>
                <td>姓:</td>
                <td><input type="text" name="" /></td>
            </tr>
            <tr>
                <td>名:</td>
                <td><input type="text" name="" /></td>
            </tr>
        </table>
        <hr />
        <table>
            <tr>
                <td><h3>性别:</h3></td>
            </tr>
            <tr>
                <td><input type="radio" name="sex" />男</td>
            </tr>
            <tr>
                <td><input type="radio" name="sex" />女</td>
            </tr>
        </table>
        <hr />
        <table>
            <tr>
                <td><h3>班级:</h3></td>
            </tr>
            <tr>
                <td>
                    <select>
                        <option>计科1班</option>
                        <option>计科2班</option>
                        <option>计科3班</option>
                    </select>
                </td>
            </tr>
        </table>
        <hr />
        <table>
            <tr>
                <td><h3>寝室:</h3></td>
            </tr>
            <tr>
                <td>
                    <select>
                        <option>12</option>
                        <option>13</option>
                        <option>14</option>
                    </select>
                </td>
                <td>舍<input type="text" name=""></td>
            </tr>
        </table>
    </form>
</body>

首先,table里的内容都需要放在td里,你的内容错乱,就是因为内容没用td包裹,会自动提前到前边。

如果想要在table里边添加hr,一个是需要用td包裹,再是td需要合并单元格。但是hr长度最多跟table这么大。想加宽可以给hr添加width属性。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/13120811.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-06-04
下一篇 2023-06-04

发表评论

登录后才能评论

评论列表(0条)

保存