Maison > Questions et réponses > le corps du texte
想让鼠标离开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;
}
伊谢尔伦2017-04-17 11:46:34
<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>
这样修改可以达到你要的效果
怪我咯2017-04-17 11:46:34
把a标签和p放在同一个p中,js设置这个父级p的hover方法,也可以把p放在a标签内,把a标签设置display: block;再用定位、浮动等调整位置。