문제

I know this is a classical one but I find no answer on the net:

I have this html code:

<div class="comment>
  <div class="myLinks">Some Links</div>
  <div class="comment">
    <div class="myLinks">Some Links</div>
  </div>
</div>

Then I have this css (written in scss):

.myLinks {
  display: hidden;
}

.comment {
  &:hover {
    .myLinks {
      display: visible;
    }
  }
}

When the pointer goes above the first comment block, the nested one's hover effect is also activated. What I want is my links to be visible only in the comment being hovered, not in his parents or children.

How can I do this? Thanks!

도움이 되었습니까?

해결책

.myLinks{
  display:none;
}

.comment:hover > .myLinks {
  display: block;
}

다른 팁

Used to this css

.myLinks{
display:none;
}

.comment:hover .myLinks{
display:block;
}

Demo

or

-------

.myLinks{
    visibility:hidden;
    }

    .comment:hover .myLinks{
    visibility: visible;
    }

Demo2

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top