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

CSS Reference Manual

CSS @rules (RULES)

Comprehensive CSS Properties

CSS3 flex-Usage and examples of shrink attribute

flex-The shrink CSS attribute specifies the shrinkage method of the flex item relative to other items in the flex container.

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

Default Value:1
Applicable To:Flexible Elements
Inheritance:No
Animatable:Yes.Please refer to Animation Attributes.
Version: CSS3new feature
JavaScript syntax:object.style.flexShrink="5"

flex-The syntax of shrink usage

The syntax of this attribute is as follows:

flex-shrink: number | initial | inherit

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

.flex-container {
    display: flex;
} 
.item1 {
    width: 100px;
    background: #ff80c0;
    -webkit-flex-shrink: 1; /* Safari 6.1+ */
    flex-shrink: 1;
}
.item2 {
    width: 100px;
    background: #8080ff;
    -webkit-flex-shrink: 3; /* Safari 6.1+ */
    flex-shrink: 3;
}
.item3 {
    width: 100px;
    background:#0080ff;
    -webkit-flex-shrink: 5; /* Safari 6.1+ */
    flex-shrink: 5;
}
Test see‹/›

Attribute Value

The following table describes the value of this attribute.

ValueDescription
numberA positive number used to determine the flex-The shrink coefficient of the shrinkable item. The default value is1.Negative numbers are invalid.
initialSet this attribute to its default value.
inheritIf specified, the associated elements adopt the flex of their parent element.-The value of shrink attribute.

Browser Compatibility

flex-Browser compatibility of shrink attribute, the numbers in the table below represent the minimum version number of 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+

For further reading

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

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