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
Nick Manring
11,369 PointsCentering text (HTML/CSS)
I'm having trouble centering text on buttons for a web page styled with CSS. I can center them of I want it to be static on the page/button, but I want the buttons to flex with the page. Horizontal centering is working fine but vertical centering is where I'm stuck. Do I have to have the line-height be static? I just want the text inside a div/box to float in the center ... Help! Best video on here is fine or a bit of code to play with would be so helpful!
4 Answers
Hayden Taylor
5,076 PointsPost some code.
You could try css text-align:center; and vertical-align: middle;
Andrei Mondoc
4,380 PointsI don't know if I am right but with a padding with a value in percentages should work. Anyway a screenshot of your code will help us to understand what is going on.
Raúl Barrera C.
18,943 PointsIf the height of buttons is static, try apply some padding on top and bottom.
Nick Manring
11,369 Points**Vertical-align: middle** is just what i needed thank you! I swear I did not see that on any website references that are usually really good