visibility
可以应用transition
的效果, 但是 display:none
会破坏 transition
的效果使用: display:none;
使用: visibility:hidden; 有过渡效果
代码:
<div class="content">
<span>visibility:hidden;</span>
<div class="box2"></div>
</div>
<style>
.content{
width: 200px;
height: 200px;
/* background: pink; */
margin: 200px auto;
position: relative;
}
.content .box2{
width: 100%;
height: 100%;
/* background: green; */
background: url(https://z3.ax1x.com/2021/05/26/2CSZ2q.jpg)no-repeat;
background-size: cover;
transition:all 0.5s linear;
visibility:hidden;
transition-delay:0s; /* 延迟效果 */
opacity: 0;
}
.content:hover .box2{
visibility:visible;
opacity: 1;
}
</style>
原文:https://www.cnblogs.com/cl1998/p/14815230.html