当表格单元格有 2 个 href 元素时,为什么要在表格单元格中添加额外的间距
一图胜千言。注意最后一行和其余行之间的空格。
这是代码。
<html>
<head></head>
<style type="text/css">
td a {
text-decoration: none;
color: black;
font-size:11px;
font-family: Arial,
}
</style>
<body>
<table>
<tr>
<td width="120px"><a href="#" target="__blank">Now is the time for all good men to come to the aide of their country said the quick brown fox to the lazy cow.</a> <a href="#" target="__blank">Moo</a></td>
</tr>
</body>
</html>
如果我取出第二个 a 标签并将 Moo 文本包含在第一个 a 标签中,间距就会消失。这是怎么回事?
Picture's worth a thousand words. Note the space between the last line and the rest.
Here's the code.
<html>
<head></head>
<style type="text/css">
td a {
text-decoration: none;
color: black;
font-size:11px;
font-family: Arial,
}
</style>
<body>
<table>
<tr>
<td width="120px"><a href="#" target="__blank">Now is the time for all good men to come to the aide of their country said the quick brown fox to the lazy cow.</a> <a href="#" target="__blank">Moo</a></td>
</tr>
</body>
</html>
If I take out the second a tag and include the Moo text within the first a tag, the spacing goes away. What's going on here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
现在您缺少结束
td
和table
标记。他们可能是问题所在。它对我来说使用结束标签效果很好:
示例: http://jsfiddle.net/bmNRq/
Right now you are missing closing
td
andtable
tags. They could be the issue.It works fine for me with the closing tags:
Example: http://jsfiddle.net/bmNRq/
在我看来,您已将
a
标记内的字体大小发送为小于默认大小。这意味着两个a
标签之间的空格字符将以标准字体大小(例如 14px)呈现,从而使其所在的行比其他行更高。尝试将 CSS 更改为:
It looks to me like you have sent the font size within the
a
tag to a smaller-than-default size. This means that the space character between the twoa
tags is being rendered in the standard font size (e.g. 14px) and thus is making the line it is on higher than the others.Try changing your CSS to: