<display-outside> - CSS(层叠样式表) 编辑
The <display-outside>
keywords specify the element’s outer display
type, which is essentially its role in flow layout. 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-inside>
keywords.
语法
<display-outside>
的可用值:
block
- 这个值会生成一个块级元素盒子,同时在该元素之前和之后打断(换行)。简单来说就是,这个值会将该元素变成块级元素。
inline
- 这个值会生成一个行内元素盒子,该元素之前和之后不会打断(换行)。如果空间充足,该元素后的元素将会在同一行显示。简单来说就是,这个值会将该元素变成行内元素。
run-in
- 这个值生成一个run-in盒子。如果其后的兄弟元素是块级盒子,那么这个run-in盒子就会以兄弟元素的第一个行内元素盒子的形式存在;如果其后的兄弟元素是行内元素,那么这个run-in盒子会变成块级元素。
- run-in元素的存在形式取决于相邻的元素,如果它的内部存在block box,那么它会变成块级元素盒子。
Note: Browsers that support the two value syntax, on finding the outer value only, such as when display: block
or display: inline
is specified, will set the inner value to flow
. This will result in expected behavior; for example if you specify an element to be block, you would expect that the children of that element would participate in block and inline normal flow layout.
举例
In the following example, span elements (normally displayed as inline elements) are set to display: block
and so break onto new lines and expand to fill their container in the inline dimension.
HTML
<span>span 1</span>
<span>span 2</span>
CSS
span {
display: block;
border: 1px solid rebeccapurple;
}
Result
Specifications
Specification | Status |
---|---|
CSS Display Module Level 3 display-outside | Candidate Recommendation |
浏览器兼容性
BCD tables only load in the browser
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.其它
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论