height

介绍

指定了一个元素的高度。
默认情况下,这个属性决定的是边框区域(border-box)的高度,但是如果将box-sizing设置为content-box, 这个属性决定的将是内容区域(content area)的高度。

取值

  • auto 默认值 lynx 根据一些条件决定具体值。

  • max-content 将宽度定义为内容最大宽度。

  • <length> 将高度定义为一个绝对值。

  • <percentage> 将高度定义为相对包含块高度的百分比。

  • <fit-content> 在内容最大高度及 fit-content 定义值中取最小值。

样例:

/* <length> values */
height: 120px;
height: 10em;

/* <percentage> value */
height: 75%;

/* Keyword values */
height: max-content;
height: fit-content(20em);
height: auto;
1
2
3
4
5
6
7
8
9
10
11

标准化语法

auto | <length> | <percentage> | max-content | fit-content
1

与 Web 的区别

暂时不支持 inherit、initial、revert、unset、max-content 等取值。

默认内容区域与 web 不一致,为box-sizing:border-box;

Last Updated: 2022/7/15 下午7:22:06