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.
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!