Non-standard This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.
This is a property for controlling parts of the XUL box model. It does not match either the old CSS Flexible Box Layout Module drafts for 'box-flex
' (which were based on this property) or the behavior of '-webkit-box-flex
' (which is based on those drafts). See flexbox for information about the current standard.
The -moz-box-flex
and -webkit-box-flex
CSS properties specify how a -moz-box
or -webkit-box
grows to fill the box that contains it, in the direction of the containing box's layout.
/* <number> values */ -moz-box-flex: 0; -moz-box-flex: 2; -moz-box-flex: 3.5; -webkit-box-flex: 0; -webkit-box-flex: 2; -webkit-box-flex: 3.5; /* Global values */ -moz-box-flex: inherit; -moz-box-flex: initial; -moz-box-flex: unset; -webkit-box-flex: inherit; -webkit-box-flex: initial; -webkit-box-flex: unset;
Syntax
The box-flex
property is specified as a <number>
. If the value is 0, the box does not grow. If it is greater than 0, the box grows to fill a proportion of the available space.
Notes
The containing box allocates the available extra space in proportion to the flex value of each of the content elements.
Content elements that have zero flex do not grow.
If only one content element has nonzero flex, then it grows to fill the available space.
Content elements that have the same flex grow by the same absolute amounts.
If the flex value is set using the element's flex
attribute, then the style is ignored.
To make XUL elements in a containing box the same size, set the containing box's equalsize
attribute to the value always
. This attribute does not have a corresponding CSS property.
A trick to make all content elements in a containing box the same size, is to give them all a fixed size (e.g. height: 0
), and the same box-flex
value greater than zero (e.g. -moz-box-flex: 1
).
Formal definition
Initial value | 0
|
Applies to | elements that are direct children of an element with a CSS display value of -moz-box or -moz-inline-box or -webkit-box or -webkit-inline-box
|
Inherited | no |
Computed value | as specified |
Animation type | discrete |
Formal syntax
<number>
Examples
Setting box-flex
<!DOCTYPE html>
<html>
<head>
<title>-moz-box-flex example</title>
<style>
div.example {
display: -moz-box;
display: -webkit-box;
border: 1px solid black;
width: 100%;
}
div.example > p:nth-child(1) {
-moz-box-flex: 1; /* Mozilla */
-webkit-box-flex: 1; /* WebKit */
border: 1px solid black;
}
div.example > p:nth-child(2) {
-moz-box-flex: 0; /* Mozilla */
-webkit-box-flex: 0; /* WebKit */
border: 1px solid black;
}
</style>
</head>
<body>
<div class="example">
<p>I will expand to fill extra space</p>
<p>I will not expand</p>
</div>
</body>
</html>
Specifications
Not part of any standard.
Browser compatibility
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.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Chrome Full support 1 Full support 1 Prefixed' Implemented with the vendor prefix: -webkit- |
Edge Full support 12 Full support 12 Prefixed' Implemented with the vendor prefix: -webkit- |
Firefox Full support 1 Full support 1 Prefixed' Implemented with the vendor prefix: -moz- Full support 49 Prefixed' Implemented with the vendor prefix: -webkit- Full support 48 Prefixed' Implemented with the vendor prefix: -webkit-
Disabled' From version 48: this feature is behind the |
IE
No support No |
Opera Full support 15 Full support 15 Prefixed' Implemented with the vendor prefix: -webkit- |
Safari Full support 3 Full support 3 Prefixed' Implemented with the vendor prefix: -webkit- No support 1.1 — 3 Prefixed' Implemented with the vendor prefix: -khtml- |
WebView Android Full support ≤37 Full support ≤37 Prefixed' Implemented with the vendor prefix: -webkit- |
Chrome Android Full support 18 Full support 18 Prefixed' Implemented with the vendor prefix: -webkit- |
Firefox Android Full support 4 Full support 4 Prefixed' Implemented with the vendor prefix: -moz- Full support 49 Prefixed' Implemented with the vendor prefix: -webkit- Full support 48 Prefixed' Implemented with the vendor prefix: -webkit-
Disabled' From version 48: this feature is behind the |
Opera Android Full support 14 Full support 14 Prefixed' Implemented with the vendor prefix: -webkit- |
Safari iOS Full support 1 Full support 1 Prefixed' Implemented with the vendor prefix: -webkit- |
Samsung Internet Android Full support 1.0 Full support 1.0 Prefixed' Implemented with the vendor prefix: -webkit- |
Legend
- Full support
- Full support
- No support
- No support
- Non-standard. Expect poor cross-browser support.'
- Non-standard. Expect poor cross-browser support.
- Deprecated. Not for use in new websites.'
- Deprecated. Not for use in new websites.
- User must explicitly enable this feature.'
- User must explicitly enable this feature.
- Requires a vendor prefix or different name for use.'
- Requires a vendor prefix or different name for use.
See also
box-flex by Mozilla Contributors is licensed under CC-BY-SA 2.5.