By default, a DIV's height is determined by its contents.
But, I override that and explicitly set a height with jQuery:
$('div#someDiv').height(someNumberOfPixels);
How can I reverse that? I want to remove the height style and to make it go back to it's automatic/natural height?
Setting the value of a style property to an empty string — e.g. $('#mydiv'). css('color', '') — removes that property from an element if it has already been directly applied, whether in the HTML style attribute, through jQuery's . css() method, or through direct DOM manipulation of the style property.
jQuery height() Method The height() method sets or returns the height of the selected elements.
height:100vh The . box class has only 100vh which is 100% of the viewport height. When you set the height to 100vh, the box element will stretch its height to the full height of the viewport regardless of its parent height.
to remove the height:
$('div#someDiv').css('height', ''); $('div#someDiv').css('height', null);
like John pointed out, set height to auto
:
$('div#someDiv').css('height', 'auto');
(checked with jQuery 1.4)
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