A navigation pattern where one or more elements are separated from the rest of the navigation items.
Requirements
A common navigation pattern is to have one element pushed away from the others. We can use Flexbox to achieve this, without needing to make the two sets of items into two separate flex containers.
Recipe
Choices made
This pattern combines auto margins with Flexbox to split the items.
An auto margin absorbs all available space in the direction it is applied. This is how centering a block with auto margins works — you have a margin on each side of the block trying to take up all of the space, thus pushing the block into the middle.
In this case the left auto margin takes up any available space and pushes the item over to the right. You could apply the class push
to any item in the list.
Browser compatibility
The various layout methods have different browser support. See the charts below for details on basic support for the properties used.
Flexbox
| Desktop | Mobile |
---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | Android webview | Chrome for Android | Firefox for Android | Opera for Android | Safari on iOS | Samsung Internet |
---|
flex | Chrome
Full support
29-
Full support
29
-
Full support
21
- Prefixed Implemented with the vendor prefix: -webkit-
| Edge
Full support
12-
Full support
12
-
Full support
12
- Prefixed Implemented with the vendor prefix: -webkit-
| Firefox
Full support
20-
Full support
20
- Notes Since Firefox 28, multi-line flexbox is supported.
- Notes Before Firefox 32, Firefox wasn't able to animate values starting or stopping at
0 . - Notes Until Firefox 61, flex items that are sized according to their content are sized using
fit-content , not max-content . -
No support
18 — 28
- Disabled From version 18 until version 28 (exclusive): this feature is behind the
layout.css.flexbox.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config. -
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
layout.css.prefixes.webkit preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
| IE
Full support
11-
Full support
11
- Notes Internet Explorer 11 ignores uses of
calc() in the flex-basis part of the flex syntax. This can be worked around by using the longhand properties instead of the shorthand. See Flexbug #8 for more info. - Notes Internet Explorer 11 considers a unitless value in the
flex-basis part to be syntactically invalid (and will thus be ignored). A workaround is to always include a unit in the flex-basis part of the flex shorthand value. See Flexbug #4 for more info. -
Full support
10
- Prefixed Implemented with the vendor prefix: -ms-
- Notes Internet Explorer 10 and 11 ignore uses of
calc() in the flex-basis part of the flex syntax. This can be worked around by using the longhand properties instead of the shorthand. See Flexbug #8 for more info. - Notes Internet Explorer 10 and 11 consider a unitless value in the
flex-basis part to be syntactically invalid (and will thus be ignored). A workaround is to always include a unit in the flex-basis part of the flex shorthand value. See Flexbug #4 for more info.
| Opera
Full support
12.1 | Safari
Full support
9-
Full support
9
-
Full support
6.1
- Prefixed Implemented with the vendor prefix: -webkit-
| WebView Android
Full support
4.4-
Full support
4.4
-
Full support
≤37
- Prefixed Implemented with the vendor prefix: -webkit-
| Chrome Android
Full support
29-
Full support
29
-
Full support
25
- Prefixed Implemented with the vendor prefix: -webkit-
| Firefox Android
Full support
20-
Full support
20
- Notes Since Firefox 28, multi-line flexbox is supported.
- Notes Before Firefox 32, Firefox wasn't able to animate values starting or stopping at
0 . - Notes Until Firefox 61, flex items that are sized according to their content are sized using fit-content, not max-content.
-
No support
18 — 28
- Disabled From version 18 until version 28 (exclusive): this feature is behind the
layout.css.flexbox.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config. -
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
layout.css.prefixes.webkit preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
| Opera Android
Full support
12.1 | Safari iOS
Full support
9-
Full support
9
-
Full support
7
- Prefixed Implemented with the vendor prefix: -webkit-
| Samsung Internet Android
Full support
2.0-
Full support
2.0
-
Full support
1.5
- Prefixed Implemented with the vendor prefix: -webkit-
|
---|
Legend
-
Full support
- Full support
- See implementation notes.
- See implementation notes.
- 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