align-items
Lesson 8 of 15 in Coddy's CSS Flexbox - The Complete Course course.
The align-items property defines the alignment along the cross axis.
The cross axis is horizontal for column direction and vertical for row direction.
It accepts five values:
flex-start- aligns the items to the start of the cross axis.flex-end- aligns the items to the end of the cross axis.center- aligns the items to the center of the cross axis.stretch- items stretch to fill the container in cross axis.baseline- items are aligned such as their baselines align.
The default value of a flex container is stretch.
Example,
.container {
display: flex;
align-items: center;
}Challenge
EasyDefine the alignment along the cross axis of the given flexbox to center.
You should try all the values!
Try it yourself
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
</body>
</html>All lessons in CSS Flexbox - The Complete Course
2Flex Container
Flexboxflex-directionflex-wrapflex-flowjustify-contentalign-itemsalign-contentgapPerfect Center