非标
此特征是非标准的,且不在标准轨道中。不要在面向 Web 的生产站点中使用它:它不适用于每个用户。实现之间可能存在大的不兼容性,且行为将来可能改变。

This is a property of the original CSS Flexible Box Layout Module draft, and has been replaced by a newer standard. See flexbox for information about the current standard.

box-lines CSS property determines whether the box may have a single or multiple lines (rows for horizontally oriented boxes, columns for vertically oriented boxes).

/* Keyword values */
box-lines: single;
box-lines: multiple;
/* Global values */
box-lines: inherit;
box-lines: initial;
box-lines: unset;
					

By default a horizontal box will lay out its children in a single row, and a vertical box will lay out its children in a single column. This behavior can be changed using the box-lines property. The default value is single , which means that all elements will be placed in a single row or column, and any elements that don't fit will simply be considered overflow.

If a value of multiple is specified, however, then the box is allowed to expand to multiple lines (that is, multiple rows or columns) in order to accommodate all of its children. The box must attempt to fit its children on as few lines as possible by shrinking all elements down to their minimum widths or heights if necessary.

If the children in a horizontal box still do not fit on a line after being reduced to their minimum widths, then children are moved one by one onto a new line, until the elements remaining on the previous line fit. This process can repeat to an arbitrary number of lines. If a line contains only a single element that doesn't fit, then the element should stay on that line and overflow out of the box. The later lines are placed below the earlier lines in normal direction boxes and above in reverse direction boxes. The height of a line is the height of the largest child in that line. No additional space appears between the lines apart from the margins on the largest elements in each line. For calculating the height of a line, margins with a computed value of auto should be treated as having a value of 0.

A similar process occurs for children in a vertical box. Later lines in normal direction boxes are placed to the right of earlier lines and to the left in reverse direction boxes.

Once the number of lines has been determined, elements with a computed value for box-flex other than 0 stretch as necessary in an attempt to fill the remaining space on the lines. Each line computes flexes independently, so only elements on that line are considered when evaluating box-flex and box-flex-groups . The packing of elements in a line, as specified by the box-pack property, is also computed independently for each line.

句法

box-lines property is specified as one of the keyword values listed below.

single

Box elements lay out in a single row or column.

multiple

Box elements layout in multiple rows or columns.

形式定义

初始值 single
适用于 box elements
继承 no
计算值 如指定
动画类型 discrete

形式句法

single | multiple
					

范例

Simple usage example

In the original version of the spec, box-lines allowed you to specify that you wanted your flex container's children to wrap onto multiple lines. This was only supported in WebKit-based browsers, with a prefix.

div {
  display: box;
  box-orient: horizontal;
  box-lines: multiple;
}
					

The modern flexbox equivalent is flex-wrap .

规范

Not part of any standard.

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
box-lines 弃用 非标 Chrome 不支持 1 — 67 Prefixed
不支持 1 — 67 Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
Edge 不支持 No Firefox 不支持 No IE 不支持 No Opera 不支持 15 — 54 Prefixed
不支持 15 — 54 Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
Safari 完整支持 3 Prefixed
完整支持 Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
不支持 1.1 — 3 Prefixed
Prefixed Implemented with the vendor prefix: -khtml-
WebView Android 不支持 ≤37 — 67 Prefixed
不支持 ≤37 — 67 Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
Chrome Android 不支持 18 — 67 Prefixed
不支持 18 — 67 Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
Firefox Android 不支持 No Opera Android 不支持 14 — 48 Prefixed
不支持 14 — 48 Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
Safari iOS 完整支持 1 Prefixed
完整支持 Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
Samsung Internet Android 不支持 1.0 — 9.0 Prefixed
不支持 1.0 — 9.0 Prefixed
Prefixed Implemented with the vendor prefix: -webkit-

图例

完整支持

完整支持

不支持

不支持

非标。预期跨浏览器支持较差。

非标。预期跨浏览器支持较差。

弃用。不要用于新网站。

弃用。不要用于新网站。

要求使用供应商前缀或不同名称。

要求使用供应商前缀或不同名称。

另请参阅

元数据

  • 最后修改: