我有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