<分区>
我正在尝试让一个(绝对定位的)div 从 bottom: 0 过渡到它的父 div 的 top: 0。例如,我可以很高兴地让它从 bottom: 0 过渡到 bottom: 10rem,但不能过渡到 top: 0。有什么想法吗?请参阅下面的代码示例,并提前致谢!
.container {
position: relative;
height: 20rem;
width: 20rem;
border: solid blue 0.05rem;
}
.child {
position: absolute;
display: inline-block;
height: 5rem;
width: 5rem;
background-color: red;
bottom: 0;
top: auto;
transition: all 1s;
}
.child:hover {
top: 0;
bottom: auto;
}
<div class="container">
<div class="child"></div>
</div>