链接之间的未知空间
我有三个链接:
<a href="/about" class="f_link"> About </a>
<a href="/Login" class="f_link"> Login </a>
<a href="/Create Account" class="f_link"> Create Account </a>
我有一些 CSS 样式:
.f_link{
height:38px;
padding-top:12px;
margin:0px;
color:gray;
}
.f_link:hover{
color:black;
text-decoration:none;
}
How this html is displayed in FF 3.6, IE 8, and some version of Google Chrome:
这就是我希望它在我的三个主要浏览器中显示的方式:
我使用了 firebug,它说这些链接之间没有填充或边距。那么那个空间是做什么用的,我怎样才能摆脱它呢?我愿意接受建议!
I have three links:
<a href="/about" class="f_link"> About </a>
<a href="/Login" class="f_link"> Login </a>
<a href="/Create Account" class="f_link"> Create Account </a>
I have some CSS styling for them:
.f_link{
height:38px;
padding-top:12px;
margin:0px;
color:gray;
}
.f_link:hover{
color:black;
text-decoration:none;
}
How this html is displayed in FF 3.6, IE 8, and some version of Google Chrome:
And this is how I would like it to be displayed in my three major browers:
I used firebug and it said there is no padding or margin between these links. What is that space there for then, and how can I get rid of it? I'm open to suggestions!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
换行符在 HTML 中被视为单个空格。您可以将标记更新为此(结束标记之前换行,但下一个 A 标记之前没有空格)
Line breaks are/should be treated as a single white space in HTML. You can update your markup to this (line break before the closing tag, but no space before the next A tag)
将
float: left;
添加到.f_link
声明中,这将删除空格。http://jsfiddle.net/wMwEQ/
另外,使用
对于间距来说是baaaad,尽管这在这里不是问题。
Add
float: left;
to your.f_link
declaration, that will remove spaces.http://jsfiddle.net/wMwEQ/
Also, using
for spacing is baaaad, even though it's not an issue here.
您可能想要稍微改变您的布局以获得您正在寻找的结果......加上这个:
确实没有必要。
那应该做你想做的事。
You may want to slightly change your layout to get the results you're looking for...plus this:
Is really unnecessary.
That should do what you want.
空格是
结束标记和后面的
开始标记之间的空格。删除标记中的空格,您应该会获得所需的效果。
The space is the spaces between the
</a>
closing tag and the following<a>
opening tag. Remove that space in your markup and you should have the desired effect.解决此问题的一种方法是将所有链接包含在一个 div 中,并设置该 div 的
font-size:0;
,然后根据需要设置链接的字体大小。您可以查看下面的小提琴以获取更多信息
fiddle
One solution to this problem is also to include all the links in a div and set the div's
font-size:0;
then set the font-size of the links as you wish.You can check the fiddle below for more info
fiddle