<flex>

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2020.

<flex> CSS 数据类型 表示了网格(grid)容器中的一段可变长度。于 grid-template-columnsgrid-template-rows 及相关属性中使用。

语法

<flex> 数据类型为一 <number> 后加单位 fr。与所有 CSS 尺寸相同,单位与数字间无空格。

示例

css
1fr    /* 使用整型 */
2.5fr  /* 使用浮点 */

规范

Specification
CSS Grid Layout Module Level 2
# fr-unit

浏览器兼容性

BCD tables only load in the browser

参见