how to center a div in bootstrap code example

Example 1: center a div in css

.container {
  display: flex;
  justify-content: center;
  align-items: center;
}

Example 2: bootstrap 4 center div

<div class="d-flex justify-content-start">...</div>
<div class="d-flex justify-content-end">...</div>
<div class="d-flex justify-content-center">...</div>
<div class="d-flex justify-content-between">...</div>
<div class="d-flex justify-content-around">...</div>

Example 3: centralize div bootstrap

<div class="row align-items-center justify-content-center">
    <div class="col">This will be centered vertically and horizontally</div>
</div>

Example 4: align eliment in center of row bootstrap

<div class="row justify-content-center">
  ...inner divs and content...
</div>

Example 5: bootstrap center align columns

<!-- Center columns in a Row -->
<div class="row d-flex justify-content-center text-center">
    <div class="col-4">
        // Add Content
    </div>
    <div class="col-4">
        // Add Content
    </div>
    <div class="col-4">
        // Add Content
    </div>
</div>

Example 6: how to center vertically in bootstrap col

<div class="my-auto">
  ...inner divs and content...
</div>

Tags:

Java Example