Show hidden inline-block elements with jquery 1.9

你说的曾经没有我的故事 提交于 2019-12-24 14:09:55

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!