jQuery .show() a flex box

前端 未结 9 1270
南笙
南笙 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:39

    I know it is a little too late (3 years) but this is the way I managed to do it.

    I created a rule in css for my div, for example #myDiv, that goes like this

    #myDiv[style*='block'] {
        display: inline-flex !important;
    }
    

    It takes advantage of what jQuery does to the DOM, it applies 'display:block'. I used inline-flex because i needed it for what i'm doing, but it can be whatever you want. In this way the rule goes faster applied without any flickering.

提交回复
热议问题