Align the flex items in the middle of the container in CSS

Use the align-items property with value center to align flex items in the middle.


You can try to run the following code to implement the center value

Live Demo

<!DOCTYPE html>
         .mycontainer {
            display: flex;
            background-color: orange;
            align-items: center;
            height: 150px;
            width: 600px;
         .mycontainer > div {
            background-color: white;
            text-align: center;
            line-height: 40px;
            font-size: 25px;
            width: 100px;
            margin: 5px;
      <div class = "mycontainer">

Updated on: 06-Jul-2020


Kickstart Your Career

Get certified by completing the course

Get Started