如何在鼠标悬停时在wordpress中的类别标题中隐藏代码?

时间:2018-11-11 10:14:38

标签: css wordpress

类别标题的任一侧我都想显示一个图标。这是我的代码:

<i class="fa fa-tree" style="color: #fcae03;"></i> Christmas Hampers <i class="fa fa-tree" style="color: #fcae03;"></i>

该代码有效,但是如何使鼠标悬停时仅显示“圣诞节礼篮”?

我对代码的了解有限,请问有人可以帮助我吗?谢谢! :)

1 个答案:

答案 0 :(得分:0)

如果我理解的正确,您只希望显示2个树形图标,并在鼠标悬停(悬停)上显示“圣诞节礼篮”。然后尝试此代码。

如果您有任何问题,请发表评论:)

<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous"> <!-- Probably you don't need to apply this line -->

<div class="christmas-hampers-wrapper">
  <i class="fa fa-tree inline-block" style="color: #fcae03;"></i>
  <div class="christmas-hampers-wrapper inline-block">
    <div class="christmas-hampers">Christmas Hampers</div>
  </div>
  <i class="fa fa-tree inline-block" style="color: #fcae03;"></i>
</div>
<style>
.inline-block{
  position: inherit;
  display: inline-block;
}
.christmas-hampers-wrapper > .christmas-hampers-wrapper{
  overflow: hidden;
  display: inline-block;
  width: 0px; height: 18px;
  transition: .3s;
}
.christmas-hampers-wrapper > .christmas-hampers-wrapper > .christmas-hampers{
  width: 127px;
}
.christmas-hampers-wrapper:hover > .christmas-hampers-wrapper{
  display: inline-block;
  width: 127px; height: 18px;
}
</style>