English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS reference manual

CSS @rules

CSS attribute大全

CSS3 flex-Usage and examples of wrap attribute

flex-The wrap CSS attribute specifies whether to force the flex items to be placed on a single line or to be placed in multiple lines or columns according to the available space in the flex container.

The following table provides usage instructions and version history of this attribute, as well as the usage syntax of this attribute in JavaScript scripts.

Default value:nowrap
Applicable to:Flexible container
Inheritance:None
Animatable:No.Please see Animation properties.
Version: CSS3new feature
JavaScript syntax:object.style.flexWrap="wrap-reverse"

flex-Syntax of wrap usage

The syntax of this attribute is as follows:

flex-wrap: nowrap | wrap | wrap-reverse | initial | inherit

The following examples demonstrate how to use flex-wrap attribute.

.flex-container {
    /* Safari */
    display: -webkit-flex;
    -webkit-flex-wrap: nowrap;
    
    display: flex;
    flex-wrap: nowrap;
}
Test see‹/›

Attribute values

The following table describes the values of this attribute.

ValueDescription
nowrapDefault value. Specify that flexible items will not be split into lines or columns.
wrapSpecify if necessary, the flexible items will be split into multiple lines.
wrap-reverseSame as wrap, but items will be wrapped in the opposite order.
initialSet this property to its default value.
inheritIf specified, the associated elements will use their parent element's flex-Wrap attribute values.

Browser compatibility

flex-Browser compatibility of the wrap attribute, the numbers in the table below represent the minimum version number of the browsers that support this attribute; all mainstream browsers support this attribute.

  • Firefox18+ -moz-,28+

  • Google Chrome 21+ -webkit-,29+

  • Internet Explorer 11+

  • Apple Safari 6.1+ -webkit-

  • Opera 12.1+

Further reading

Please refer to the following tutorials:CSS3Multi-column layout.

Related properties:align-content,align-items,align-self,display,flex,flex-basis,flex-direction,flex-flow,flex-grow,flex-shrink,justify-content,min-height,min-width,order.