max-height
max-height 规定元素设置最大高度,且能阻止height属性的设置值比max-height大。
max-height 可覆盖 height , min-height 可覆盖 max-height。
语法
/* <length> value */ max-height: 2.5em; /* <percentage> value */ max-height: 95%; /* Keyword values */ max-height: none; max-height: max-content; max-height: min-content; max-height: fit-content; max-height: fill-available; max-height: inherit;
值
例子
HTML
<div id="red"> Hudaokeji. </div>
CSS
#red { width: 200px; max-height: 300px; margin: auto; background: red; text-align: center; }
执行结果
Hudaokeji.