Change color of icon when hovering over div in which it is contained

旧巷老猫 提交于 2021-02-10 18:34:16

问题


How can I invert the color of the icon fa fa-clipboard when hovering over the wrap div?

<div class="col-lg-6 mbr-col-md-10">
    <div class="wrap">
        <div class="ico-wrap">
            <span class="mbr-iconfont fa fa-clipboard"></span>
        </div>
    </div>
</div>

This will invert the color of the clipboard icon when I hover over the icon itself, but I need it to invert when hovering over the div above it. The default color is black.

.mbr-iconfont:hover {
  color: white !important;
}

回答1:


Try this syntax:

.outer:hover .inner {
  color: red;
}
<div class="outer">
  <span class="inner">Lorem</span>
</div>

Hopefully it helps




回答2:


.ico-wrap:hover .mbr-iconfont {
  color: white !important;
}

.ico-wrap {
  border: 1px solid black;
  width: 100px;
}
<div class="col-lg-6 mbr-col-md-10">
  <div class="wrap">
    <div class="ico-wrap">
      <span class="mbr-iconfont fa fa-clipboard"> text here </span>
    </div>
  </div>
</div>


来源:https://stackoverflow.com/questions/59740562/change-color-of-icon-when-hovering-over-div-in-which-it-is-contained

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!