CSS
-Tricks
treehouse :
what would you like to learn today?
Web Design
Web Development
iOS Development
Show search box
Search
Search in:
All
Articles
Forums
Snippets
Videos
✕
Home
Forums
Snippets
Gallery
Videos
Almanac
Demos
Lodge
Navigation 'n' Search
Forums
Illustration by Nick Sirotich
Forums
»
CSS Combat
How do I center these Nav buttons?
smithaa99
Permalink to comment
#
January 2011
http://www.parkarvidsonacupuncture.com/wordpress/index.php
I'm trying to figure out the right CSS to center the text on the buttons.
It'd be cool to center all of it in relation to the main container as well, but that's secondary.
Thanks much,
Adam
chrisburton
Permalink to comment
#
January 2011
Try
text-align: center;
smithaa99
Permalink to comment
#
January 2011
Basically what I'm trying to do is line up the text centered over the buttons like this:
http://www.parkarvidsonacupuncture.com/ParkArvidson/TEST.html
How would I go about that?
dhechler
Permalink to comment
#
January 2011
make your #main-nav width: 150px; then your text-align: center; will look correct.
smithaa99
Permalink to comment
#
January 2011
dhechler, you rock. Thanks for your help as well Christopher.
smithaa99
Permalink to comment
#
January 2011
Okay you're gonna love me guys, now I need help vertically centering this text within the button. My client wants this to mirror the template to a T.
http://www.parkarvidsonacupuncture.com/wordpress/#
chrisburton
Permalink to comment
#
January 2011
use padding. Also, your home link font visually looks smaller than the rest.
TheDoc
Permalink to comment
#
January 2011
For vertical alignment, what you can do is take the height of the nav and apply that to the line-height as well.
For example, if you nav button was 50px tall, you would apply line-height: 50px;
noahgelman
Permalink to comment
#
January 2011
Ah yes, the classic line-height equal to button height. Works every time.
Add a Comment
I'm trying to figure out the right CSS to center the text on the buttons.
It'd be cool to center all of it in relation to the main container as well, but that's secondary.
Thanks much,
Adam
http://www.parkarvidsonacupuncture.com/ParkArvidson/TEST.html
How would I go about that?
http://www.parkarvidsonacupuncture.com/wordpress/#
For example, if you nav button was 50px tall, you would apply line-height: 50px;