📜  将鼠标悬停在父元素上时如何将过渡应用到子元素 - CSS 代码示例

📅  最后修改于: 2022-03-11 14:47:42.700000             🧑  作者: Mango

代码示例1
.parent {
    background: red;
}
.child {
    overflow: hidden;
    height: 0;
    background: blue;
    -webkit-transition: all .8s ease;
    -moz-transition: all .8s ease;
    -ms-transition: all .8s ease;
    -o-transition: all .8s ease;
    transition: all .8s ease;
    color: white;
}
.parent:hover > .child {
    height: 30px;
    display: block;
}