问题
I've problem with showing hidden blocks, if they are css: inline-block.
div.profile{
display: inline-block;
}
<div class='profile' style='display: none;'>profile info</div>
But when i do $('.profile').show() it becomes style='display: block' (i can see it in firebug) and overrites my css style...
How can i fix this?
btw, in jquery 1.4 it works correctly.
Thanks.
UPD
$.css('display', 'inline-block'), imo, is not universal solution.
回答1:
You should change the css style instead of using the show
function, which changes it to block
.
$('.profile').css('display', 'inline-block');
回答2:
$('.profile').css('display', 'inline-block')
回答3:
While setting it explicitly to inline-block
works in this case, you should ideally be setting it to ''
to apply whatever comes from the CSS, be it inline
, or inline-block
or block
$('.profile').css('display', ''); // switch it back to whats specified in the CSS
来源:https://stackoverflow.com/questions/15952965/show-hidden-inline-block-elements-with-jquery-1-9