2

i was wondering if anyone can assist in what it should have been a straight forward issue to fix when it comes to aligning the text ("CONSOL Overview") in the middle instead of left in the title box below.

I have tried "align-content: center" and also "text-align: center" but that doesn't seem to be working.

Any help apprecieated

my html page looks like this: enter image description here

and the part in the html code is this:

<div class="container-fluid" style="padding-top: 15px;">
    <div class="row" 
         style="height: 50px;padding-top: 15px; background: #36304a; align-content: center; color: white; font-weight: bold; border-radius: 10px">
        <h3>CONSOL Overview</h3>
    </div>
</div>

Actually there more elements below my title but i guess those aren't needed to be shown here.

davidism
  • 121,510
  • 29
  • 395
  • 339
SNicolaou
  • 550
  • 1
  • 3
  • 15

3 Answers3

9

If you are using Bootstrap 4 or newer, then the row class is display: flex by default, which means <div class="row justify-content-center"> should place every item in your div horizontally center. If you want to it horizontally and vertically center then use <div class="row justify-content-center align-items-center">

The other way is, if your containers height is set, then simply make your text's line-height equal with it and it will be in center. (works only if the text is only in one row)

Ihtisham Khan
  • 417
  • 5
  • 20
Patrik Alexits
  • 987
  • 9
  • 24
3

I think you are using Bootstrap and there is a really easy way to align elements in the center using mx-auto like <div class="mx-auto"> or <h3 class="mx-auto">. :)

Vipul Sharma
  • 525
  • 9
  • 23
0

Hi Here is solution to your problem

    h3{
display: inline-block;
    margin: 0 auto;
}

Working fiddle

Liaqat Saeed
  • 428
  • 5
  • 17