如何在不使用CSS的情况下并排获得两个TD单元
在下面的 HTML 代码片段中,我希望两个单元格并排放置,并且它们之间没有空格;如果可能的话不使用CSS。如果第二个最左边的位置是第一个最右边的位置,为什么它们之间会有空格?谢谢。
<TR>
<TD style="position:absolute; top:98px; left:0px; right:56px; bottom:126px; font-size: 7pt; background-color:Lime; text-align: center; font-family: Arial;" cellpadding="0" cellspacing="0">ABC</TD>
<TD style="position:absolute; top:98px; left:56px; right:112px; bottom:126px; font-size: 7pt; background-color:Lime; text-align: center; font-family: Arial;" cellpadding="0" cellspacing="0">123</TD>
in the following HTML snippet, I would like the two cells be placed side by side with NO spaces between them; without using css if possible. If the leftmost position of the 2nd one is the rightmost position of the 1st, why WOULD they have any space between? thx.
<TR>
<TD style="position:absolute; top:98px; left:0px; right:56px; bottom:126px; font-size: 7pt; background-color:Lime; text-align: center; font-family: Arial;" cellpadding="0" cellspacing="0">ABC</TD>
<TD style="position:absolute; top:98px; left:56px; right:112px; bottom:126px; font-size: 7pt; background-color:Lime; text-align: center; font-family: Arial;" cellpadding="0" cellspacing="0">123</TD>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么要绝对定位表格单元格?它们会自动相邻渲染。如果我没记错的话,你需要做的就是 border-spacing="0" 。不过用 css 会容易得多 =)
Why absolutely position your table cells? They automatically render next to each other. All you need to do is border-spacing="0" if I remember correctly. It'd be much easier with css though =)
我不完全确定我理解这个问题...源中它们之间的空格将被浏览器忽略,并且应该将它们放在一起。
您想删除单元格之间的填充吗?尝试将
style="border-collapse:collapse"
添加到元素。但更好的方法是将样式转移到 css 文件中,因为那里有很多事情要做。
编辑:啊,现在我注意到其中的
position:absolute
。去掉它(以及与之相伴的top
、right
、bottom
和left
)。I'm not entirely sure I understand the question... The space in between them in the source will be ignored by the browser, and should put them next to each other.
Do you want to remove the padding between the cells? Try adding
style="border-collapse: collapse"
to the<table>
element. But even better would be to move your styling over to a css file, since you've got so much going on there.edit: Ah, now I notice the
position: absolute
in there. Get rid of that (and thetop
,right
,bottom
, andleft
that go with it).