The max-height attribute sets the maximum height of the element.
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!