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-content property flex-start value
The CSS align-content property with the flex-start value aligns flex lines to the beginning (top) of the flex container. This property only works when there are multiple lines of flex items, which requires flex-wrap: wrap to be set.
Syntax
selector {
align-content: flex-start;
}
Example
The following example demonstrates how align-content: flex-start positions flex lines at the top of the container −
<!DOCTYPE html>
<html>
<head>
<style>
.mycontainer {
display: flex;
height: 200px;
width: 400px;
background-color: lightblue;
align-content: flex-start;
flex-wrap: wrap;
border: 2px solid #333;
}
.mycontainer > div {
background-color: orange;
text-align: center;
line-height: 60px;
font-size: 20px;
width: 80px;
height: 60px;
margin: 5px;
border-radius: 5px;
}
</style>
</head>
<body>
<h2>Flex Container with align-content: flex-start</h2>
<div class="mycontainer">
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
<div>Item 4</div>
<div>Item 5</div>
<div>Item 6</div>
</div>
</body>
</html>
A light blue flex container with orange rounded items arranged in multiple rows, all positioned at the top of the container with remaining space below.
Key Points
-
align-content: flex-startonly affects multi-line flex containers - Requires
flex-wrap: wraporflex-wrap: wrap-reverse - Positions all flex lines at the start of the cross axis (top by default)
- Any extra space appears after the flex lines
Conclusion
The align-content: flex-start property is useful for aligning multiple rows of flex items to the top of the container, leaving any remaining space at the bottom.
Advertisements
