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-start value
The CSS align-items property with the flex-start value aligns flex items to the start of the cross axis, which is typically the top of the container in a horizontal flex layout.
Syntax
.container {
display: flex;
align-items: flex-start;
}
Example
You can try to run the following code to implement the flex-start value −
<!DOCTYPE html>
<html>
<head>
<style>
.mycontainer {
display: flex;
height: 300px;
background-color: red;
align-items: flex-start;
padding: 10px;
}
.mycontainer > div {
background-color: orange;
text-align: center;
line-height: 60px;
font-size: 30px;
width: 100px;
height: 60px;
margin: 5px;
color: white;
border-radius: 5px;
}
</style>
</head>
<body>
<h1>Quiz</h1>
<div class="mycontainer">
<div>Q1</div>
<div>Q2</div>
<div>Q3</div>
<div>Q4</div>
</div>
</body>
</html>
A red container with four orange boxes labeled Q1, Q2, Q3, Q4 aligned to the top (flex-start) of the container. The boxes appear in a horizontal row at the top of the red container.
Conclusion
The align-items: flex-start property ensures that all flex items are aligned to the beginning of the cross axis, making it perfect for top alignment in horizontal layouts.
Advertisements
