Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
Usage of CSS align-items property flex-end value
The CSS align-items property with the flex-end value is used to align flex items to the end of the cross-axis, which is typically the bottom of the flex container when using the default row direction.
Syntax
selector {
display: flex;
align-items: flex-end;
}
Example
The following example demonstrates how to align flex items to the bottom of their container using align-items: flex-end −
<!DOCTYPE html>
<html>
<head>
<style>
.mycontainer {
display: flex;
height: 300px;
background-color: #e74c3c;
align-items: flex-end;
padding: 10px;
border: 2px solid #333;
}
.mycontainer > div {
background-color: #f39c12;
text-align: center;
line-height: 60px;
font-size: 24px;
width: 100px;
height: 60px;
margin: 5px;
color: white;
font-weight: bold;
border-radius: 5px;
}
</style>
</head>
<body>
<h2>Quiz Items Aligned to Bottom</h2>
<div class="mycontainer">
<div>Q1</div>
<div>Q2</div>
<div>Q3</div>
<div>Q4</div>
</div>
</body>
</html>
A red container with four orange quiz items (Q1, Q2, Q3, Q4) aligned to the bottom of the container. Each item is a rounded rectangle with white text, positioned horizontally in a row but vertically aligned to the flex container's bottom edge.
Conclusion
The align-items: flex-end property effectively moves all flex items to the bottom of their container along the cross-axis. This is particularly useful for creating bottom-aligned navigation bars, footers, or any layout where content needs to stick to the bottom edge.
Advertisements
