jQuery fadeOut without display none?

后端 未结 6 908
死守一世寂寞
死守一世寂寞 2020-12-08 03:54

Is there an alternative to fadeOut() that doesn\'t use display:none for the style? I\'d like to just use visibility hidden to avoid any sort of shifting in the page layout?

6条回答
  •  心在旅途
    2020-12-08 04:22

    Note that

    fadeTo(500, 0)   // fade out over half a second
    fadeTo(0, 0)     // instantly hide
    

    is (oddly) not compatible with

    fadeIn()
    

    (when you want to show it again). So if you are using

    fadeTo(500, 0)

    in order to to hide something without the css display: none then you must use

    fadeTo(500, 1)

    to fade it back in or it will still have opacity: 0 left over in the css and will remain invisible.

提交回复
热议问题