作爲標題,我使用.icon-*
添加圖標。當添加的圖標到超鏈接::懸停:文字修飾之前沒有任何效果?
<a href="#" class="icon-email icon-large">Email me!</a>
通過content
屬性插入的內容示出了上懸停下劃線文字修飾。我想只爲內容禁用text-decoration
前:
[class^="icon-"]:before, [class*=" icon-"]:before {
font-family: 'IcoMoon';
font-style: normal;
speak: none;
}
.icon-mail:before {
content: "\37";
}
[class^="icon-large-"]:before, [class*=" icon-large"]:before {
font-size: 48px;
line-height: 48px;
}
a[class^="icon-"]:before, a[class*=" icon-"]:before {
margin-right: 5px;
vertical-align: middle;
}
我已經試過這一點,但它不工作(裝飾仍清晰可見):
a[class^="icon-"]:hover:before, a[class*=" icon-"]:hover:before {
text-decoration: none;
color: white;
}
你不能做到這一點與pseudoelements。你將不得不使用JS。 – Bojangles 2012-07-13 16:47:03
是的,你不能雙倍pseusoelements和pseudoclasses那樣沒有js。我會建議使用JavaScript來處理:之前,而不是處理:懸停。這是因爲:之前並不是所有瀏覽器都支持。但這只是我的2美分.. – BumbleB2na 2012-07-13 16:47:25
@ BumbleB2na至少IE8 +,FF10.0.2 +,Opera 11.61+,Safari 5.1.2+,Chrome 17 http://www.quirksmode.org/css/contents.html – gremo 2012-07-13 16:57:22