# max-height

CSS属性 max-height 设置元素的最大高度。它防止height属性的使用值(used value)大于 max-height 的指定值。

# uni-app x 兼容性

Android iOS web
3.9 4.11 4.0

# 语法

max-height: <viewport-length>;

# max-height 的属性值

fit-content 元素的最大高度根据内容可用高度自适应,当不会超过内容的最大高度 max-content 值。

max-content 元素的最大高度可以扩展到内容的最大高度。

min-content 元素的最大高度限制在内容的最小高度之内。

auto 元素的高度可以根据其内容的高度自动扩展,但仍然受到其他相关属性(如 heightmin-height)的影响。如果没有其他限制,元素的高度将扩展以适应内容。

none 元素的高度不再受到任何最大高度的限制,即使元素的内容很多,也会根据内容的大小来自动扩展。

# 默认值

none

# 兼容性

# max-height 的属性值兼容性

Android iOS web
fit-content x x 4.0
max-content x x 4.0
min-content x x 4.0
auto x x 4.0
none x x 4.0

# 浏览器兼容性

Chrome Edge Firefox Opera Safari IE
max-height √( 18 ) √( 12 ) √( 1 ) √( 7 ) √( 1.3 ) √( 7 )
fit-content √( 18 ) √( 12 ) √( 1 ) √( 7 ) √( 1.3 ) √( 7 )
max-content √( 18 ) √( 12 ) √( 1 ) √( 7 ) √( 1.3 ) √( 7 )
min-content √( 18 ) √( 12 ) √( 1 ) √( 7 ) √( 1.3 ) √( 7 )

# 参见