前端 - a:hover时滑出div2,想在鼠标离开a到了div2上面该div2依旧显示,移到其它地方还是保留a:hover效果。
怪我咯
怪我咯 2017-04-17 11:44:34
0
4
595

想让鼠标离开a元素移到p2上p2依旧显示,但是移到a元素和p2以外的地方就还是不显示

<a href="#">hover</a>
    <p class="p2">
        
    </p>
a:hover + .p2{
        display: block;    
        animation: 0.5s p2 ease-in forwards;
        
    }
    @keyframes p2{
        0%{height: 0; }
        100%{height: 200px; }
    } 
    .p2{
        width: 200px;
        background-color: red;
        
    }
怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(4)
黄舟

Take .p2 as a child element of the a tag, and then use position: absolute to adjust the position

伊谢尔伦
<a href="#">hover
<p class="p2">

</p>
</a>
<style>
  a:hover .p2{
    display: block;
    animation: 0.5s p2 ease-in forwards;

  }
  @keyframes p2{
    0%{height: 10px; }
    100%{height: 200px; }
  }
  .p2{
    width: 200px;
    background-color: red;

  }
</style>

这样修改可以达到你要的效果
刘奇

Put the a tag and p in the same p, and js sets the hover method of the parent p. You can also put p in the a tag, set the a tag to display: block; and then adjust it with positioning, floating, etc. Location.

小葫芦

If this is the case, why not put p in the A tag

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template