【发布时间】:2019-10-20 09:18:00
【问题描述】:
解决方案: 我找到的解决方案是在彼此之上使用两个 div(为了使功能更清晰,我将其中一个 div 设置为红色),虽然它必须为两个 div 设置动画效果,但它仍然应该比使用 javascript 更清洁和更快:
.outerDiv {
width: 100%;
height: 50px;
position: relative;
}
.hover1 {
height: 50px;
width: 50px;
background: black;
position: relative;
top: 0px;
transition: width 1s
}
.hover2 {
height: 50px;
width: 50px;
background: red;
position: relative;
top: -50px;
transition: width 1s 1s
}
.outerDiv:hover .hover2 {
width: 100%;
transition: width 0s 0.9s;
}
.outerDiv:hover .hover1 {
width: 100%;
transition: width 1s;
}
<div class="outerDiv">
<div class="hover1"></div>
<div class="hover2"></div>
</div>
【问题讨论】:
标签: css hover css-transitions delay