CSS transition from `display: none` on class change?

后端 未结 4 1102
一生所求
一生所求 2020-12-14 14:41

I\'ve started using transitions to \"modernise\" the feel of a site. So far, :hover transitions are working great. Now I\'m wondering if it\'s possible to trigg

4条回答
  •  臣服心动
    2020-12-14 15:12

    It is possible to animate show and hide elements in css, just instead of:

    display: none;
    
    /* and */
    
    display: block;
    

    use:

    overflow: hidden;
    max-height: 0;
    
    /* and */
    
    max-height: 9999999px;
    

    Since you replace this properties, you are able to animate any css value with transition.

    working example: https://jsfiddle.net/utyja8qx/

提交回复
热议问题