question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bootstrap 4: heading won't align to center

See original GitHub issue

Hi, I’m starting to fix my css since I just updated our website’s bootstrap source code to version 4.

I’ve got an issue with regards to aligning the heading to center. I’ve tried the following options:

option 1:

#sectionname h2 {
text-align: center;
}

option 2:

#sectionname h2 {
text-align: center!important;
}

option 3: (the latest i’ve added) <h2 class="text-center">How does it work?</h2>

still, it won’t work. I’ve shared a screen cap for reference.

untitled

Any help will be appreciated. Much love to bootstrap!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
ghostcommented, Aug 18, 2017

Since your screenshot shows that it is between row try using mx-auto

<div class='row'>
  <h2 class='mx-auto'>hello</h2>
</div>
3reactions
mdocommented, Aug 18, 2017

Columns should be the only children elements of a row. Rows are flexbox, thus your heading is behaving as a flex item.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bootstrap center heading - Stack Overflow
It is my first Twitter Bootstrap experience. I have added some headings (h1, h2, etc.) and they are aligned by left side. What...
Read more >
Text · Bootstrap v4.6
Documentation and examples for common text utilities to control alignment, wrapping, weight, and more.
Read more >
CSS · Bootstrap
Rows must be placed within a .container (fixed-width) or .container-fluid (full-width) for proper alignment and padding. · Use rows to create horizontal groups ......
Read more >
Text · Bootstrap v5.0
Easily realign text to components with text alignment classes. For start, end, and center alignment, responsive classes are available that use the same ......
Read more >
Navs - Bootstrap
Change the horizontal alignment of your nav with flexbox utilities. By default, navs are left-aligned, but you can easily change them to center...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found