如何在<a>

时间:2016-08-08 13:47:51

标签: css hover

How can i add background for <span> when mouse hover <span> or <a>.

<a href="" class="special"><span class="fa fa-facebook"></span> Facebook</a>

enter image description here

中添加效果悬停在跨度上

1 个答案:

答案 0 :(得分:0)

CSS就是选择元素。您希望在悬停父span标记时选择<a>。只需使用a:hover > span即可。

#activation:hover > #activated {
  color:red;
}
<a id="activation" href="" class="special">
  <span id="activated" class="fa fa-facebook">?</span>
  <span>Facebook</span>
</a>