为什么我的表格中的最后 3 行单元格没有与 HTML 表格中的第一行完美对齐?
单击左上角的预览JS Bin 菜单栏可以看到这个示例的工作原理。您可以看到带有电子邮件和输入字段的表格单元格的顶部 2 个边框比左侧 2 个表格单元格的顶部 2 个边框稍低其中(用户名和输入字段)。
为什么会发生这种情况?
另外我发现我必须在第二个元素中为 和
元素编写
rowspan="4"
让它们跨越旁边的 3 行。为什么我必须这样做?如果我只需要清除 3 行,那就没有意义了。就好像某处隐藏着一个神秘的行。
更新示例答案:
我在这个示例中实现了答案。 如您所见,有所有表格单元格之间完美对齐。
Here is a link my example of the misaligned table rows
Click preview in the upper top left corner of the JS Bin menu bar to see this example in the works. You can see the top 2 borders of the table cells with Email and an input field in them are a bit lower than the top 2 borders of the 2 table cells to the left of them (Username and an input field).
Why is this happening?
Also I am finding I have to write rowspan="4"
for <th>
and <td>
elements in the second element to make them span the 3 rows beside it. Why do I have to do that? It makes no sense if there are only 3 rows I have to clear. It's as if there is a mysterious hidden row somewhere.
UPDATE with example answer:
I implemented the answer in this example. As you can see, there is perfect alignment between all table cells.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对...简单...
基本上,第二行需要有 4 个单元格,用户名和输入单元格以及电子邮件和输入单元格...
用户名和输入单元格需要有
rowspan=" 3"
然后接下来的两行需要是密码和新密码及其输入字段。代码:
right... easy peasy...
basically, the second row needs to have 4 cells in it, the username and input cells AND the email and input cells...
the username and input cells need to have
rowspan="3"
and then the NEXT two rows need to be password and new password with their input fields.code:
您的第一行有 1 个 td,colspan 为 4,但您的第二行有 2 个 td,并且 colspan 为正常?
您的标记有缺陷,请先修复此问题。
最终结果应该是什么样子?
现在的样子?
Your first row is has 1 td with a colspan of 4, but your second row is 2 td's both with a normal colspan?
Your mark up is flawed, fix this first.
What is the end result supposed to look like?
The way it looks now?