CSS flexbox – display flex and inline-flex

CSS property display can be used to define flex box container. It can have two values:

  1. display: flex;
  2. display: inline-flex;

Syntax:

.someflexcontainer {
  display: flex;
}

Example – display:flex and inline-flex

In the following code, CSS property display can be changed to the following values
  • flex
  • inline-flex
<style>
.fbox {
  display: flex;
  flex-direction: row;
  width: 200px; background-color:gray;
}
.child {
  background-color:lightblue;
  padding: 3px; margin: 3px;
}
</style>

<div class=fbox>
<div class="child">div1</div>
<div class="child">div2</div>
<div class="child">div3</div>
<div class="child">div4</div>
</div>
<div class=fbox>
<div class="child">div1</div>
<div class="child">div2</div>
<div class="child">div3</div>
<div class="child">div4</div>
</div>
display refresh

Specification and Browser compatibility

SpecificationStatusCategories
Flexible Box Layout ModuleW3C Working DraftCSS3
Desktop
ChromeFirefoxIEEdgeSafariOpera
Yes 29+ Yes 28+ Partial 11+ Yes 12+ Yes 9+ Yes 12.1+
Mobile
Android ChromeAndroid FirefoxiOS SafariIE MobileOpera Mobile
Yes 47+ Yes 44+ Yes 9.0-9.2+ Yes 11+ Yes 12.1+
source: caniuse.com
Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments