无边框厚度的 CSS
我有一张用 0px
边框构建的表格,我试图让每一行中的图像彼此无缝配合,但即使边框没有显示,仍然有一个 行之间有 1px
间隙。有办法解决这个问题吗?
table {
border-collapse: collapse;
border-spacing: 0px;
font-size: 10px;
}
table th, table td {
padding: 0px;
margin: 0px;
border-width: 0px;
}
tr {
padding: 0px;
margin: 0px;
border-collapse: collapse;
border-spacing: 0px;
}
I have a table that I built out with 0px
border, and I am trying to get images in each row to fit seamlessly to one another but even though the border does not show there is still a 1px
gap in between the rows. Is there a way to fix this?
table {
border-collapse: collapse;
border-spacing: 0px;
font-size: 10px;
}
table th, table td {
padding: 0px;
margin: 0px;
border-width: 0px;
}
tr {
padding: 0px;
margin: 0px;
border-collapse: collapse;
border-spacing: 0px;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
可能是表格内的内容创建了一些额外的空间,并且您没有提到什么浏览器,但请注意 IE7 不支持边框折叠,因此您应该
在 IE7 的表格中添加:。另外,没有理由对 tr 应用
border-collapse
。Might be that the content inside the table is creating some extra space, and you didn't mention what browser, but be aware that IE7 doesn't understand border-collapse so you should add:
to the table for IE7. Also, there is no reason to apply
border-collapse
to the tr.我认为
border-spacing
适用于表格。您是否尝试过border: none
作为tr
元素?I think
border-spacing
is for a table. Did you tryborder: none
for thetr
element?试试这个:
CSS
HTML
Try this:
CSS
HTML
您是否尝试过
display: block
来显示图像?did you try
display: block
for images?感谢您的回复,我在 HTML 中设置了 cellspacing="0",并尝试了您的所有建议。似乎没有人改变结果,我现在唯一的想法是我正在 Mac 上工作,这是某种浏览器问题。我得在电脑上测试一下,看看效果如何。
Thanks for the responses, I had the cellspacing="0" in the HTML, and tried all your suggestions. None seemed to change the outcome, my only thought now is that I'm working on a Mac and that it is some kind of browser issue. I'll have to test it on a PC and see how it looks.