Home  >  Article  >  Web Front-end  >  How to set the maximum height in css

How to set the maximum height in css

王林
王林Original
2021-05-14 16:01:365867browse

The way to set the maximum height in css is to use the max-height attribute, such as [max-height:50px;], which means setting the maximum height to 50px.

How to set the maximum height in css

The operating environment of this article: windows10 system, css 3, thinkpad t480 computer.

The max-height attribute in css can set the maximum height of an element.

Attribute value:

  • none Default. The definition places no limit on the maximum height allowed for an element.

  • #length defines the maximum height of the element.

  • % Defines the maximum height based on the percentage of the block-level object that contains it.

  • #inherit Specifies that the value of the max-height attribute should be inherited from the parent element.

Example:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title></title> 
<style>
p
{
	max-height:50px;
	background-color:yellow;
}
</style>
</head>

<body>
<p>这一段的最大高度设置为50 px。这一段的最大高度设置为50 px。这一段的最大高度设置为50 px。这一段的最大高度设置为50 px。这一段的最大高度设置为50 px。这一段的最大高度设置为50 px。这一段的最大高度设置为50 px。这一段的最大高度设置为50 px。这一段的最大高度设置为50 px。这一段的最大高度设置为50 px。</p>
</body>
</html>

Related recommendations: css video tutorial

The above is the detailed content of How to set the maximum height in css. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn