jQuery .show() a flex box

前端 未结 9 1291
南笙
南笙 2021-02-06 20:56

I have an element with a flexbox

    div#myFlexbox{ display:flex; }

after hide it and show it, it gets messed up.<

9条回答
  •  醉梦人生
    2021-02-06 21:38

    Since other answers did not account for the possibility that you might be using the duration argument...

    Short Answer: Use .hide for hiding the value and that shouldn't happen.

    A little explanation:

    The matched elements will be hidden immediately, with no animation. This is roughly equivalent to calling .css( "display", "none" ), except that the value of the display property is saved in jQuery's data cache so that display can later be restored to its initial value. If an element has a display value of flex and is hidden then shown, it will once again be displayed flex.

    From documentation, Changed 'inline' to 'flex' to fit the contenxt!

    So jQuery knows what you're hiding! If you've hidden it using .hide that is, And it knows how to show it again with the right display value.

提交回复
热议问题