Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS Bootstrap 4 Basics (Retired) Using Bootstrap Components Adding Buttons and Button Groups

Shunsuke Taguchi
Shunsuke Taguchi
9,380 Points

How center a button

I tried to center a button but it didn't work. Did I miss anything?

<button type="button" class="btn btn-outline-info btn-lg center-block m-y-3">Don't miss out! Register Now</button>
Erik Nuber
Erik Nuber
20,629 Points

just a note, won't fix the issue but it should be btn-info-outline you have it reversed.

I've looked at your code closely and it matches exact otherwise to the code in the video.

Ryan Oakes
Ryan Oakes
9,787 Points

I was experiencing the same thing! I investigated and apparently .center-block was removed in favor of .m-x-auto.

I'd follow Jorge's example down below!

Same question was asked elsewhere~ Add the class of "d-block" & "m-x-auto" to correct the issue!

1 Answer

Jorge Soto
Jorge Soto
5,379 Points

Hi, I managed to do it like this.

<button type="button" class="btn btn-outline-info d-block m-x-auto">
Don't Miss Out Register Now
</button>

"d-block" changes the display property to "block" and well, Guil already explained m-x-???, I just added "auto" and it worked.

I guess Bootstrap has changed something in our version.

Obaa Cobby
Obaa Cobby
9,337 Points

Just for future learners, use "mx-auto" //new syntax with Bootstrap-4.