min-height
The min-height CSS property specifies the minimum height of the box.
CSS
JS
object.style.minHeight = "value";
Values
<'min-height'> = auto | <length-percentage> | min-content | max-content | fit-content( <length-percentage> )
auto
Automatically specified by the user agent.
<length-percentage> = [ <length> | <percentage> ]
<length>
Specifies the length using a number followed by a unit of measurement.
<percentage>
Specifies the percentage using a number followed by a percent sign (%).
min-content
Represents the largest min-content contribution of the items occupying the track.
max-content
Represents the largest max-content contribution of the items occupying the track.
fit-content()
Represents the formula max(minimum, min(limit, max-content)), where minimum represents an auto minimum (which is often, but not always, equal to a min-content minimum), and limit is the track sizing function passed as an argument to fit-content(). This is essentially calculated as the smaller of minmax(auto, max-content) and minmax(auto, limit).
Initial
auto
fit-content
<!doctype html>
<html>
<head>
<style>
div {
background-image: linear-gradient(135deg, white, gray);
height: 100px;
}
div:nth-of-type(1) {
background-image: linear-gradient(135deg, white, yellow);
min-height: fit-content(200px);
}
</style>
</head>
<body>
<div>fit-content</div>
<div>fit-content</div>
<div>fit-content</div>
</body>
</html>
length
<!doctype html>
<html>
<head>
<style>
div {
background-image: linear-gradient(135deg, white, gray);
height: 100px;
}
div:nth-of-type(1) {
background-image: linear-gradient(135deg, white, yellow);
min-height: 200px;
}
</style>
</head>
<body>
<div>length</div>
<div>length</div>
<div>length</div>
</body>
</html>
max-content
<!doctype html>
<html>
<head>
<style>
div {
background-image: linear-gradient(135deg, white, gray);
height: 100px;
}
div:nth-of-type(1) {
background-image: linear-gradient(135deg, white, yellow);
min-height: max-content;
}
</style>
</head>
<body>
<div>max-content</div>
<div>max-content</div>
<div>max-content</div>
</body>
</html>
min-content
<!doctype html>
<html>
<head>
<style>
div {
background-image: linear-gradient(135deg, white, gray);
height: 100px;
}
div:nth-of-type(1) {
background-image: linear-gradient(135deg, white, yellow);
min-height: min-content;
}
</style>
</head>
<body>
<div>min-content</div>
<div>min-content</div>
<div>min-content</div>
</body>
</html>
percentage
<!doctype html>
<html>
<head>
<style>
div {
background-image: linear-gradient(135deg, white, gray);
height: 100px;
}
div:nth-of-type(1) {
background-image: linear-gradient(135deg, white, yellow);
min-height: 200%;
}
</style>
</head>
<body>
<div>percentage</div>
<div>percentage</div>
<div>percentage</div>
</body>
</html>
JS
<!doctype html>
<html>
<head>
<style>
div {
background-image: linear-gradient(135deg, white, gray);
height: 100px;
}
div:nth-of-type(1) {
background-image: linear-gradient(135deg, white, yellow);
}
</style>
<script>
function mouseover(value) {
document.getElementsByTagName("div")[0].style.minHeight = value;
}
</script>
</head>
<body>
<input onmouseover="mouseover(value)" type="button" value="auto">
<button onmouseover="mouseover(value)" value="fit-content(200px)">fit-content</button>
<button onmouseover="mouseover(value)" value="200px">length</button>
<input onmouseover="mouseover(value)" type="button" value="max-content">
<input onmouseover="mouseover(value)" type="button" value="min-content">
<button onmouseover="mouseover(value)" value="200%">percentage</button>
<div>min-height</div>
<div>min-height</div>
<div>min-height</div>
</body>
</html>
Internal
External