Material Box

Material Box

WEB Design & Material Images

CSS - Align Child Elements to Bottom with FlexBox

CSS

How to align child elements to the bottom with CSS FlexBox, with code examples.


The HTML has a container element with class "container" and multiple <div> child elements.

<div class="container">
	<div></div><div></div><div></div><div></div><div></div>
</div>

To align child elements to the bottom in FlexBox, set "align-items" to "flex-end".

The relationship between "align-items" and "justify-content" properties depends on the main and cross axis set by the "flex-direction" property.

.container {
	width: 100%;
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: flex-end;
	gap: 10px;
	padding: 10px;
	box-sizing: border-box;
	background-color: #404040; 
}

.container div {
  width: 100px;
  height: 100px;
  background-color: #4169e1;
}

.container div:nth-of-type(1) {
  height: 150px;
}
.container div:nth-of-type(2) {
  height: 100px;
}
.container div:nth-of-type(3) {
  height: 140px;
}
.container div:nth-of-type(4) {
  height: 80px;
}
.container div:nth-of-type(5) {
  height: 50px;
}

CSS - Align Child Elements to Bottom with FlexBox

TitleCSS - Align Child Elements to Bottom with FlexBox

CategoryCSS

Created

Update

AuthorYousuke.U