在下面的示例中,我使用字体为我的导航创建图标:http://www.blackcountrydesigns.co.uk/examples/green/
我遇到的问题是,当你将鼠标悬停在链接上时,链接和图标上都会出现下划线。
我想知道如何删除图标上的下划线,但保持它在链接上。
下面是我的代码:
HTML
<ul class="hidden-phone">
<li><a class="entypo-home" href="#">Home</a></li>
<li><a class="entypo-briefcase" href="#">Services</a></li>
<li><a class="entypo-picture" href="#">Portfolio</a></li>
<li><a class="entypo-address" href="#">Contact</a></li>
</ul>
CSS
#nav ul li a {color:#ccc; margin-left: 25px;}
#nav [class*='entypo-'].active:before {color:#666;}
#nav [class*='entypo-']:before {font-size: 46px; position: relative; top: 5px;left: -3px; color:#999;}
[class*='entypo-']:hover:before {text-decoration:none !important;}非常感谢
发布于 2013-03-25 07:01:25
到目前为止,我发现要从生成的内容中删除(通常)继承的样式的唯一方法是使用简化的演示(从注释中)给它position: absolute:
a:link
{
text-decoration: none;
position: relative;
margin-left: 1em;
}
a:hover
{
text-decoration: underline;
}
a:before
{
content: '#';
position: absolute;
right: 100%;
top: 0;
bottom: 0;
width: 1em;
}JS Fiddle demo。
当然,这种方法的缺点是需要将显式width分配给生成的内容(以及父a元素的margin )。
发布于 2013-03-25 07:06:27
另一种方法是将链接的文本包装在一个元素中,例如span,删除'a‘中的下划线,并将其应用于悬停时的span。
<li><a class="entypo-home active" href="#"><span>Home</span></a></li>
[class*='entypo-'] a { text-decoration: none; }
[class*='entypo-'] a:hover span { text-decoration: underline; }发布于 2013-03-25 07:02:02
恐怕那行不通。我建议给这个类设置你的<li/>,并为它们设置:before。
如果您不想使用position: absolute方法,这里是我的建议的fiddle。
https://stackoverflow.com/questions/15605010
复制相似问题