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

How to set the maximum height in css

王林
Release: 2023-01-06 11:13:17
Original
5957 people have browsed it

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template