luc*_*uca 27 html css anchor margin
我有这个样式表:
*{
padding: 0px;
margin: 0px;
}
a{
background:yellow;
}
Run Code Online (Sandbox Code Playgroud)
和这个网页:
<a href="/blog/">Home</a>
<a href="/about/">About</a>
<a href="/contact/">Contact</a>
Run Code Online (Sandbox Code Playgroud)
结果是:
如何让这些锚标签相互"接触",消除其间不需要的空间?
谢谢卢卡
Šim*_*das 29
您可以使用此技巧摆脱空间:
HTML:
<div id="test">
<a href="/blog/">Home</a>
<a href="/about/">About</a>
<a href="/contact/">Contact</a>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
#test { font-size:0; }
#test a { font-size:16px; background:yellow; }
Run Code Online (Sandbox Code Playgroud)
现场演示: http ://jsfiddle.net/quucy/
Luk*_*dek 15
我想我可能会找到一种非常酷的解决方法:-).我开始使用<!-- comments -->填充空< span >s等的事实.
因此,如果你想保持你的新线结构并且不想要它们之间的空格......只需在线的末尾打开一个块注释,然后在新线之前将其结束. < anchor >
像这样:
<div id="test">
<a href="/blog/">Home</a><!--
--><a href="/about/">About</a><!--
--><a href="/contact/">Contact</a>
</div>
Run Code Online (Sandbox Code Playgroud)
和演示:http://jsfiddle.net/Lukis/reZG2/1/