我有HTML:如何在父元素被徘徊時將css轉換應用於元素?
<div class="social-section">
<a href="#" class="glyphicons facebook"><i></i></a>
<a href="#" class="glyphicons twitter"><i></i></a>
</div>
我想,當鼠標滑過,使用CSS3過渡到有圖標淡出,以不同的顏色。不幸的是,如果可能的話,我不確定如何完成這項工作。我在CSS當前的嘗試是:
.social-section * i:before { /* Apply this to the i:before, when the a is hovered */
-webkit-transition: all 0.3s ease-in;
-moz-transition: all 0.3s ease-in;
-ms-transition: all 0.3s ease-in;
-o-transition: all 0.3s ease-in;
transition: all 0.3s ease-in;
}
.social-section a i:before {
color: red;
}
.social-section a:hover i:before {
color: black;
}
如果這是有益的,這裏的Glyphicons字體CSS代碼的相關部分:
.glyphicons {
display: inline-block;
position: relative;
padding: 0 0 5px 35px;
*display: inline;
*zoom: 1;
}
.glyphicons i:before {
position: absolute;
left: 0;
top: 0;
font: 20px/1em 'Glyphicons';
font-style: normal;
color: red;
}
你可以發表你的*得到*的[demo](http://jsfiddle.net/),並解釋它如何不工作?這樣我們就可以使用代表性的代碼,讓我們嘗試並研究發生了什麼。 –
@DavidThomas我不能給出一個實際字體的例子,但這裏有一個準確的選擇,我剛剛完成:http://jsfiddle.net/6sFCs/ – BenjaminRH