How to align vertical center image in bootstrap?

Hi Friends 👋,

Welcome To aGuideHub! ❤️

Today, I am going to show you. How to align vertical center image in bootstrap with code example.

Here, we will use .align-items: center class to make a image in vertical center.

For vertical alignment, using .display: flex is again really helpful. Consider a case where our container has a height of 700px, but the height of the image is only 500px. Now, in this case, adding a single line of code to the container, .align-items: center, does the trick.


Let’s look at the following example to understand how it basically works:

<!doctype html>
<html lang="en" class="h-100%">
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Bootstrap CSS -->
    <link href="[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">

 div {
  display: flex;
  align-items: center;
  height: 700px;

img {
  width: 60%;
  height: 500px;

  <body class="h-100%">
      <div class="container-flued h-100%">
        <div class="image">
          <img src="images/pexels-photo-257360.jpeg">

    <!-- Bootstrap Bundle with Popper -->
    <script src="[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>


The align-items property can position elements vertically if used together with display: flex.

Check the output of the above code example.

Bootstrap, Image, Vertically

All the best 👍

Premium Content

You can get all the below premium content directly in your mail when you subscribe us


Interview Questions

Soon You will get CSS, JavaScript, React Js, and TypeScript So Subscribe to it.

Portfolio Template

View | Get Source Code

Cheat Sheets

Cheat Sheets Books are basically Important useful notes which we use in our day-to-day life.

Related Posts