Setting max-height AND min-height property in CSS (or via jQuery)

css min-height not working
min-height css responsive
css max-height not working
max-height: 100
div min-height
min-height: 100
min-height not working in firefox
max-height not working in ie

I have a simple but annoying problem. I need to set min-height AND max-height of a div element.

For example: min-height: 100px and max-height: 200px. I load my page with div height 200px. If i squeeze my browser window, this div resizes and when it hits height=100px it stops resizing.

Of course min-height and max-height in CSS is not working. :/



Also set height.

min-height: 100px;
max-height: 200px;
height: 100%;

CSS max-height property, Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, PHP, Python, Bootstrap, Java  The max-height property defines the maximum height of an element. If the content is larger than the maximum height, it will overflow. How the container will handle the overflowing content is defined by the overflow property. If the content is smaller than the maximum height, the max-height property has no effect.

Min height always overwrites height and max-height, so you can't just use both.

This is kind of a hack, but you could do it with media queries. If this is your HTML:

<div id="myDiv"></div>

Then add this to your css:

@media screen and (max-height: 200px) {
    #myDiv {
        height:99vh; /*Set this with trial and error because it depends on your margins*/
@media screen and (max-height: 100px) {
    #myDiv {

CSS min-height Property, The min-height property in CSS is used to set the minimum height of a specified element. The min-height property always overrides both height and max-height . Authors may use any of the length values as long as they are a positive value. The min-height property defines the minimum height of an element. If the content is smaller than the minimum height, the minimum height will be applied. If the content is larger than the minimum height, the min-height property has no effect. Note: This prevents the value of the height property from becoming smaller than min-height.


min-height: 100px;
max-height: 200px;
height: 100vh;

min-height, . Authors may use any of the length values as long as they are a positive value. The CSS min-height is for setting the minimum height of elements. It works with positive length values. Remember that min-height replaces both max-height and height. The following example sets the height and max-height for <div>, but CSS min-height overrides both of these properties.

What is the difference between height and max-height?, What is the difference between height and max height in CSS? How to set element size width, height, max min height width « Previous; Next » You can set HTML element size using width or height property. Also you can set element maximum height width or minimum height width. CSS element size properties. following all properties are supported, all defined type value. using this properties you can set

min-height, on selector element but no space will take until no content pushed inside. But I'm in need of a small snippet that looks up the current height of a div (the div has a dynamic height based on the content inside it) and then set that value in the css class's min-height value. Basically what this means is that I want this container to have it's min-height to be the exact same value as it's current height.

Tips on CSS Height: CSS max-height Explained With Examples, Using CSS max-height property to make your website elements responsive Controlling CSS Height: Learn to Set Max-Height and Min-Height. So you might benefit from knowing and using related properties that use the “min” and “max” prefixes. min-width / min-height. The min-width and min-height properties accept unit values the exact same way that the height and width properties do, so there’s no difference in the syntax. You can use any acceptable unit, including pixels