I’m creating a portfolio using bootstrap. For some reasons i can’t get the text vertically centered. i have tried align-items-center and justify-content-center with no luck. Here is the code:
<div class="cover-container d-flex h-100 p-3 flex-column">
<h1 style="font-weight: 650;">I'm <span style="color: #2075b6">ABC</span></h1>
<h3>I'm a XYZ</h3>
</div>
I tried using align-items-center and justify-content-center with no luck.
2
Answers
To vertically center the text within the cover-container div using Bootstrap, you can try using the d-flex class along with the align-items-center and justify-content-center classes. Here’s an updated version of your code:
By adding the align-items-center and justify-content-center classes to the cover-container div along with the d-flex class, the text should be centered vertically within the container.
exemple
First create a container div for grid system in order to center the content. Then create a row and center the content vertically within the row using the ‘align-items-center’ class. Also create a column within the row and center the content horizontally using the ‘text-center’class. Note that the min-height property ensures that the row has a minimum height, which allows the content to be centered both vertically and horizontally regardless of the height of the content.