These keywords specify the element’s inner display type, which defines the type of formatting context that lays out its contents (assuming it is a non-replaced element). These keywords are used as values of the display property, and can be used for legacy purposes as a single keyword, or as defined in the Level 3 specification alongside a value from the <display-outside> keywords.

句法

Valid <display-inside> values:

flow
The element lays out its contents using flow layout (block-and-inline layout).

If its outer display type is inline or run-in , and it is participating in a block or inline formatting context, then it generates an inline box. Otherwise it generates a block container box.

Depending on the value of other properties (such as position , float ,或 overflow ) and whether it is itself participating in a block or inline formatting context, it either establishes a new block formatting context (BFC) for its contents or integrates its contents into its parent formatting context.

flow-root
The element generates a block element box that establishes a new block formatting context , defining where the formatting root lies.
table
These elements behave like HTML <table> elements. It defines a block-level box.
flex
The element behaves like a block element and lays out its content according to the flexbox model .
grid
The element behaves like a block element and lays out its content according to the grid model .
ruby
The element behaves like an inline element and lays out its content according to the ruby formatting model. It behaves like the corresponding HTML <ruby> elements.

注意 : Browsers that support the two value syntax, on finding the inner value only, such as when display: flex or display: grid is specified, will set their outer value to block . This will result in expected behavior; for example if you specify an element to be display: grid , you would expect that the box created on the grid container would be a block level box.

范例

In this example the parent box has been given display: flow-root and so establishes a new BFC and contains the floated item.

HTML

<div class="box">
  <div class="float">I am a floated box!</div>
  <p>I am content inside the container.</p>
</div>
						

CSS

.box {
    background-color: rgb(224, 206, 247);
    border: 5px solid rebeccapurple;
    display: flow-root;
}
.float {
    float: left;
    width: 200px;
    height: 150px;
    background-color: white;
    border:1px solid black;
    padding: 10px;
}
						

结果

规范

规范 状态
CSS Display Module Level 3
The definition of 'display-inside' in that specification.
候选推荐

浏览器兼容性

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.

Support of multiple keyword values

更新 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
Multi-keyword values Experimental Chrome 不支持 No Edge 不支持 No Firefox 完整支持 70 IE 不支持 No Opera 不支持 No Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 不支持 No Opera Android 不支持 No Safari iOS 不支持 No Samsung Internet Android 不支持 No

图例

完整支持

完整支持

不支持

不支持

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

Support of flow-root

更新 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
flow-root Chrome 完整支持 58 Edge 完整支持 79 Firefox 完整支持 53 IE 不支持 No Opera 完整支持 45 Safari 完整支持 13 WebView Android 完整支持 58 Chrome Android 完整支持 58 Firefox Android 完整支持 53 Opera Android 完整支持 43 Safari iOS 完整支持 13 Samsung Internet Android 完整支持 7.0

图例

完整支持

完整支持

不支持

不支持

Support of table

更新 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
table , table-cell , table-column , table-column-group , table-footer-group , table-header-group , table-row ,和 table-row-group Chrome 完整支持 1 Edge 完整支持 12 Firefox 完整支持 1 IE 完整支持 8 Opera 完整支持 7 Safari 完整支持 1 WebView Android 完整支持 ≤37 Chrome Android 完整支持 18 Firefox Android 完整支持 4 Opera Android 完整支持 14 Safari iOS 完整支持 1 Samsung Internet Android 完整支持 1.0

图例

完整支持

完整支持

Support of grid

更新 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
grid Chrome 完整支持 57 Edge 完整支持 16
完整支持 16
完整支持 12 Prefixed
Prefixed Implemented with the vendor prefix: -ms-
Firefox 完整支持 52 IE 部分支持 10 Prefixed 注意事项
部分支持 10 Prefixed 注意事项
Prefixed Implemented with the vendor prefix: -ms-
注意事项 Internet Explorer implements an older version of the specification.
Opera 完整支持 44 Safari 完整支持 10.1 WebView Android 完整支持 57 Chrome Android 完整支持 57 Firefox Android 完整支持 52 Opera Android 完整支持 43 Safari iOS 完整支持 10.3 Samsung Internet Android 完整支持 6.0 注意事项
完整支持 6.0 注意事项
注意事项 Samsung Internet added this earlier than the corresponding Chrome version would indicate.

图例

完整支持

完整支持

部分支持

部分支持

见实现注意事项。

见实现注意事项。

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

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

Support of flex

更新 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
flex Chrome 完整支持 29 Edge 完整支持 12 Firefox 完整支持 20 注意事项
完整支持 20 注意事项
注意事项 Firefox 28 added multi-line flexbox support.
不支持 18 — 28 Disabled
Disabled ). To change preferences in Firefox, visit
IE 部分支持 11 注意事项
部分支持 11 注意事项
注意事项 IE incorrectly positions inline block content inside flex containers. See the discussion on Microsoft Answers .
部分支持 8 注意事项 Alternate Name
注意事项 IE incorrectly positions inline block content inside flex containers. See the discussion on Microsoft Answers .
Alternate Name Uses the non-standard name: -ms-flexbox
Opera 完整支持 16
完整支持 16
Prefixed Implemented with the vendor prefix: -webkit-
不支持 12.1 — 15
Safari 完整支持 9 WebView Android 完整支持 4.4 Chrome Android 完整支持 29 Firefox Android 完整支持 20 注意事项
完整支持 20 注意事项
注意事项 Firefox 28 added multi-line flexbox support.
不支持 18 — 28 Disabled
Disabled ). To change preferences in Firefox, visit
Opera Android 完整支持 16
完整支持 16
Prefixed Implemented with the vendor prefix: -webkit-
不支持 12.1 — 14
Safari iOS 完整支持 9 Samsung Internet Android 完整支持 2.0

图例

完整支持

完整支持

部分支持

部分支持

见实现注意事项。

见实现注意事项。

用户必须明确启用此特征。

用户必须明确启用此特征。

使用非标名称。

使用非标名称。

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

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

Support of ruby

更新 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
ruby , ruby-base , ruby-base-container , ruby-text ,和 ruby-text-container Chrome 不支持 No Edge 不支持 12 — 79 Firefox 完整支持 38
完整支持 38
不支持 34 — 38 Disabled
Disabled ). To change preferences in Firefox, visit
IE 完整支持 7 Opera 不支持 No Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 完整支持 38
完整支持 38
不支持 34 — 38 Disabled
Disabled ). To change preferences in Firefox, visit
Opera Android 不支持 No Safari iOS 不支持 No Samsung Internet Android 不支持 No

图例

完整支持

完整支持

不支持

不支持

用户必须明确启用此特征。

用户必须明确启用此特征。

另请参阅

元数据

  • 最后修改:
  1. CSS
  2. CSS 参考
  3. CSS Display
  4. 特性
    1. <display-box>
    2. <display-inside>
    3. <display-internal>
    4. <display-legacy>
    5. <display-listitem>
    6. <display-outside>
    7. display

Copyright  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1