<flex>

Baseline Widely available

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

<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

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
<flex>

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

参见