Align Flex Items along Cross Axis using CSS3

CSSWeb DevelopmentFront End Technology

To align Flex Items along Cross Axis using CSS3, the code is as follows −

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<style>
body {
   font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
.container {
   height: 200px;
   display: flex;
   width: 100%;
   align-items: center;
   border: 2px solid red;
}
div {
   width: 100px;
   height: 100px;
   color: white;
   text-align: center;
   font-size: 30px;
}
.first {
   background-color: rgb(55, 0, 255);
}
.second {
   background-color: red;
}
.third {
   background-color: rgb(140, 0, 255);
}
</style>
</head>
<body>
<h1>Align flex items along cross axis</h1>
<div class="container">
<div class="first">First Div</div>
<div class="second">Second Div</div>
<div class="third">Third Div</div>
</div>
</body>
</html>

Output

The above code will produce the following output −

raja
Published on 11-May-2020 12:32:54
Advertisements