css3 height transition not working

前端 未结 4 1012
予麋鹿
予麋鹿 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:25

    Instead of using a set height on a container or using JS (which are both awkward solutions)... You can put the images in list items and work your transition on the li.

    If all the images are going to a similar height it means your content inside the container can still be dynamic. For example...

    /*
    CLOSED
    */
    
    div.container li 
    
    {  height:0px;
    
    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
    -ms-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    transition: all 0.5s ease;}
    
    /*
    OPEN
    */
    
    div.container:hover li 
    
    {  height:30px;
    
    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
    -ms-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    transition: all 0.5s ease;}
    

提交回复
热议问题