如何使用jQuery从DIV中删除高度样式? [英] How do I remove the height style from a DIV using jQuery?

查看:941
本文介绍了如何使用jQuery从DIV中删除高度样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,DIV的高度由它的内容决定。

By default, a DIV's height is determined by its contents.

但是,我重写了并且使用jQuery显式地设置了高度:

But, I override that and explicitly set a height with jQuery:

$('div#someDiv').height(someNumberOfPixels);

如何扭转?

推荐答案

要移除高度样式,并将其恢复为自动/自然高度?

to remove the height:

$('div#someDiv').css('height', '');
$('div#someDiv').css('height', null);

像John指出的,将高度设置为 auto

like John pointed out, set height to auto:

$('div#someDiv').css('height', 'auto');

(使用jQuery 1.4检查)

(checked with jQuery 1.4)

这篇关于如何使用jQuery从DIV中删除高度样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆