CSS align-items – flexbox items vertical alignment

The align-items property can be used to align flex items in vertical diretion. It is flex container property.

Syntax:

.someflexcontainer {
  display: flex;
  alig-items: auto;
}

CSS property align-items

CSS version: CSS 3
Value: auto | flex-start | flex-end | center | baseline | stretch
Initial: auto
Applies to: flex containers
Inherited: no

align-items values

flex-start flexbox-align-items-flex-start
flex-end flexbox-align-items-flex-end
center flexbox-align-items-center
baseline flexbox-align-items-baseline
stretch flexbox-align-items-stretch

Example – align-items

In the following code, CSS property align-items can be changed to the following values
  • auto
  • flex-start
  • flex-end
  • center
  • baseline
  • stretch
<style>
.fbox {
  display: flex;
  align-items: auto;
  width: 200px; background-color:gray;
}
.child {
  background-color:lightblue;
  border: 1px solid black; padding: 5px;
}
</style>

<div class=fbox>
<div style="font-size:30px;" class="child">div1</div>
<div class="child">div2 longer text</div>
<div class="child">div3</div>
<div class="child">div4</div>
</div>
align-items 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