Html 如何在锚标签之间添加空格?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20808949/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I add space between anchor tags?
提问by B. Clay Shannon
I want to give my anchor tags some elbow room. I tried to add both padding and margin, and neither one work (even when I give them a lot, as you can see here):
我想给我的锚标签一些肘部空间。我尝试添加填充和边距,但没有一个起作用(即使我给它们很多,正如您在此处看到的那样):
a {
line-height: 1em;
display: inline-block;
text-decoration: none;
padding: 120;
margin: 42;
}
How can I add some spacing between the anchor elements?
如何在锚元素之间添加一些间距?
The entire kit and kaboodle are here: http://jsfiddle.net/clayshannon/pRgQL/
整个套件和 kaboodle 在这里:http: //jsfiddle.net/clayshannon/pRgQL/
I ended up going with this: http://jsfiddle.net/clayshannon/pRgQL/18/
我最终选择了这个:http: //jsfiddle.net/clayshannon/pRgQL/18/
回答by David says reinstate Monica
In CSS the different lengths/sizes need to have specific units, the browser doesn't guess your intent, it simply discards invalid property values, in this case I used px
, since I'm assuming that's what you wanted to use:
在 CSS 中,不同的长度/大小需要有特定的单位,浏览器不会猜测您的意图,它只是丢弃无效的属性值,在这种情况下我使用了px
,因为我假设这就是您想要使用的:
a {
line-height: 1em;
display: inline-block;
text-decoration: none;
padding: 120px;
margin: 42px;
}
Alternative units include(but are not limited to): em
, rem
, ex
, pt
, cm
(among others).
替代单位包括(但不限于): ,em
,rem
,ex
,pt
(cm
等等)。
References:
参考:
回答by Kickaha
<a>1<a/> <a>2<a/>
1 2
1 2
non breaking space if you like ..
如果您愿意,可以使用不间断空间
回答by JohnKlehm
You need to add the units to your margin and padding e.g.
您需要将单位添加到您的边距和填充中,例如
padding: 120px;
margin: 42px;
回答by Ali Gajani
Sir, I may add, that you forgot to add units to your numbers. The numbers must have units, so please try adding px
. That should do the magic for you. For example:
先生,我可以补充一点,您忘记在数字中添加单位。数字必须有单位,所以请尝试添加px
。那应该对你有魔力。例如:
a {
line-height: 1em;
display: inline-block;
text-decoration: none;
padding: 120px;
margin: 42px;
}