I have an element with a flexbox
<ul id="myFlexbox"> div#myFlexbox{ display:flex; } after hide it and show it, it gets messed up.
$('#myFlexbox').show(); now the element has a display of block instead of flex.
<ul id="myFlexbox" style="display: block;"> How can I use .hide and .show with flexboxes?
The show() Method in jQuery is used to display the hidden and selected elements. Note: This method display the hidden elements which are using CSS display: none property. The elements are not visible whose visibility is hidden.
A flex container expands items to fill available free space or shrinks them to prevent overflow. Most importantly, the flexbox layout is direction-agnostic as opposed to the regular layouts (block which is vertically-based and inline which is horizontally-based).
The show() adds display:block as a default for div. You can change the display to flex using jQuery css():
$('#myFlexbox').css('display', 'flex');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With