css3 height transition not working

前端 未结 4 961
予麋鹿
予麋鹿 2021-01-07 18:44

i have a problem using css3 transitions how can i make the transition smooth it appears instantly
i want the div box to slowly change its height when i hover over it<

4条回答
  •  执笔经年
    2021-01-07 19:02

    This solution does not need javascript or have the problem of needing to have a fixed height for the container before hand.

    This is made possible by using max-height property and setting its value to a high value.

    #imgs {
        border:1px solid #000;
        border-radius:3px;
        max-height:20px;
        width:100%;
        overflow:hidden;
        transition: 2s ease;
    }
    #imgs:hover {
        max-height:15em;
    }

提交回复
热议问题