Home  >  Article  >  Web Front-end  >  How to use css max-height attribute

How to use css max-height attribute

(*-*)浩
(*-*)浩Original
2019-05-28 16:17:362636browse

The max-height attribute sets the maximum height of the element.

How to use css max-height attribute

Description

This attribute value will set a maximum limit on the height of the element. Therefore, the element can be shorter than the specified value, but not taller. Negative values ​​are not allowed.

Note: The max-height attribute does not include margins, borders, and padding.

Value Description
none
Default. The definition places no limit on the maximum height allowed for an element.
length
Define the maximum height value of the element.
%
Defines the maximum height as a 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:

<html>
	<head>
	<style type="text/css">
		p
		{
			max-height: 10px
		}
	</style>
	</head>
	<body>

	<p>这是一些文本。这是一些文本。这是一些文本。
	这是一些文本。这是一些文本。这是一些文本。
	这是一些文本。这是一些文本。这是一些文本。
	这是一些文本。这是一些文本。这是一些文本。
	这是一些文本。这是一些文本。这是一些文本。</p>


	</body>
</html>

The above is the detailed content of How to use css max-height attribute. 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
Previous article:How to center css textNext article:How to center css text