Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boostrap v4.0.0-alpha.6 model - how to center model title

Tags:

How do you center a model's title? I tired to add the class "text-center" to the h1 tag but it keeps showing the tile left aligned.

Thanks

like image 758
Artoo Smith Avatar asked Feb 08 '17 19:02

Artoo Smith


People also ask

How do I center a Bootstrap modal title?

You can use the w-100 class on the h3. modal-title element along with text-center . Worked like a charm!

How do I center content in modal?

In this example first, use the find() method to find out the modal dialog. Then subtract the modal height from the window height and divide that into half and will place the modal that will be the centered(vertically). This solution will dynamically adjust the alignment of the modal.

How do you center align a model?

display: block; max-width: 100%; height: auto; display:block means text-align:centre which is inherited from text-center will have no effect. If you remove the . img-responsive class, your image will be centred.


2 Answers

You can use the w-100 class on the h3.modal-title element along with text-center.

<div class="modal-header text-center">   <h3 class="modal-title w-100">Quiz Results</h3> </div> 
like image 98
webprojohn Avatar answered Nov 04 '22 16:11

webprojohn


I had to figure this out today in particular when I wanted a centered modal-title inside a modal-header - played around with a few different ways but here is what I settled on:

<div class='modal-dialog' role='document'>   <div class='modal-content'>     <div class='modal-header'>       <h3 class='col-12 modal-title text-center'>         Centered Modal Title         <button type='button' class='close' data-dismiss='modal' aria-label='Close'>           <span aria-hidden='true'>&times;</span>         </button>       </h3>     </div>   </div> </div> 

The key was having col-12 if you want to do it inside of the 'modal-header' tag.

like image 26
Sava Avatar answered Nov 04 '22 15:11

Sava