li{ .subnav{ display: flex; flex-direction: column; transition:height 2s;//这个高度什么不生效 padding: 10px 0; height: 0; overflow: hidden; } } #navmenu li:hover .subnav{ height: auto; }
因为heigth:auto 不是具体值,无法触发过渡。transition 必须满足是具体值,比如 opacity:0->opacity:1。可以将height:auto用max-height:xxx代替
heigth:auto
transition
opacity:0
opacity:1
height:auto
max-height:xxx
2.1m questions
2.1m answers
60 comments
57.0k users