display的各种取值(收藏啦)

display

Read content offline

Redirected from display Redirect 1

« CSS « CSS Reference

Summary

The display CSS property specifies the type of rendering box used for an element. In HTML, default display property values are taken from behaviors described in the HTML specifications or from the browser/user default stylesheet. The default value in XML isinline.

In addition to the many different display box types, the value none lets you turn off the display of an element; when you use none, all descendant elements also have their display turned off. The document is rendered as though the element doesn't exist in the document tree.

 

  • Initial valueinline
  • Applies toall elements
  • Inheritedno
  • Mediaall
  • Computed valueas the specified value, except for positioned and floating elements and for the root element. In both case the computed value may be another keyword than the one specified.
  • Animatableno
  • Canonical orderthe unique non-ambiguous order defined by the formal grammar

 

Syntax

Formal syntax: none | inline | block | list-item | inline-block | inline-table | table | table-cell | table-column | table-column-group | table-footer-group | table-header-group | table-row | table-row-group | flex | inline-flex | grid | inline-grid | run-in
display: none
display: inline
display: block
display: list-item
display: inline-block
display: inline-table
display: table
display: table-cell
display: table-column
display: table-column-group
display: table-footer-group
display: table-header-group
display: table-row
display: table-row-group
display: flex
display: inline-flex
display: grid
display: inline-grid
display: run-in

display: inherit

Values

display-value

Is a keyword defining the rendering type to apply to the element. Its possible values and their meanings are:
Value setValueDescription
Basic values (CSS 1)none

Turns off the display of an element (it has no effect on layout); all descendant elements also have their display turned off. The document is rendered as though the element did not exist.

To render an element box's dimensions, yet have its contents be invisible, see the visibility property.

inlineThe element generates one or more inline element boxes.
blockThe element generates a block element box.
list-itemThe element generates a block box for the content and a separate list-item inline box.
Extended values (CSS 2.1)inline-blockThe element generates a block element box that will be flowed with surrounding content as if it were a single inline box (behaving much like a replaced element would)
Table model values (CSS 2.1)inline-tableThe inline-table value does not have a direct mapping in HTML. It behaves like a <table> HTML element, but as an inline box, rather than a block-level box. Inside the table box is a block-level context.
tableBehaves like the <table> HTML element. It defines a block-level box.
table-captionBehaves like the <caption> HTML element.
table-cellBehaves like the <td> HTML element
table-columnThese elements behave like the corresponding <col> HTML elements.
table-column-groupThese elements behave like the corresponding <colgroup> HTML elements.
table-footer-groupThese elements behave like the corresponding <tfoot> HTML elements
table-header-groupThese elements behave like the corresponding <thead> HTML elements
table-rowBehaves like the <tr> HTML element
table-row-groupThese elements behave like the corresponding <tbody> HTML elements
Flexbox model values (CSS3)flexThe element behaves like a block element and lays out its content according to the flexbox model.
inline-flexThe element behaves like an inline element and lays out its content according to the flexbox model.
Grid box model values (CSS3Experimentalgrid

The element behaves like a block element and lay out its content according to the grid model.

As this is experimental,  most browsers don't support it. Especially pay attention that  -moz-grid is not the prefixed version of this, but a  XUL layout model that must not be used on a Web site.
inline-gridThe element behaves like an inline element and lay out its content according to the grid model.
Experimental valuesExperimentalrun-in
  • If the run-in box contains a block box, same as block.
  • If a block box follows the run-in box, the run-in box becomes the first inline box of the block box.
  • If a inline box follows, the run-in box becomes a block box.

Examples

VIEW LIVE EXAMPLES

p.secret  { display: none }
<p style="display:none"> invisible text </p>
 

Specifications

SpecificationStatusComment
CSS Basic Box ModelUnknownAdded the run-in value.
CSS Grid LayoutWorking DraftAdded the grid box model values.
CSS Flexible Box Layout ModuleCandidate RecommendationAdded the flexible box model values.
CSS Level 2 (Revision 1)RecommendationAdded the table model values and inline-block.
CSS Level 1RecommendationBasic values: noneblockinline, and list-item.

Browser compatibility

 

  • Desktop  
  • Mobile
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
noneinline and block1.01.0 (1.0)4.07.01.0 (85)
inline-block1.03.0 (1.9)5.5 (-7.0)
natural inline elements only
7.01.0 (85)
list-item1.01.0 (1.0)6.07.01.0 (85)
run-in Experimental1.0
Not before inline-elements
Not supported8.07.01.0 (85)
Not before inline-elements
4.05.0 (532.5)
inline-table1.03.0 (1.9)8.07.01.0 (85)
tabletable-celltable-columntable-colgrouptable-header-grouptable-row-grouptable-footer-grouptable-row, and table-caption1.01.0 (1.0)8.07.01.0 (85)
flex21.0-webkit18.0 (18.0)(behind a pref) [1]Not supported12.50Not supported
inline-flex21.0-webkit18.0 (18.0)(behind a pref) [1]Not supported12.50Not supported
grid Experimental?Not supported10.0-ms??
inline-grid Experimental?Not supported10.0-ms??

转载于:https://www.cnblogs.com/lx09110718/p/display.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值