Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
Old 04-01-2008, 04:01 PM Vertical Centering
Skilled Talker

Posts: 93
Name: David Howland
Location: New England
Trades: 0
I'm trying to create a nav bar for my site with vertically centered links. I cannot figure out how to make the links vertically centered within the nav bar. Margin and padding only move the entire nav bar around, and the vertical-align item does nothing. i suspect it's a problem with the structure of my tags. Here's the offending code:

Code:
#nav {
	margin: 0px 20px 0px 20px;
	padding: 0px;
	border-bottom: 5px solid #ccc;
	border-left: 5px solid #ccc;
	border-right: 5px solid #ccc;
	background: #666666;
	height: 20px;
	}
#nav a {
	vertical-align:middle;
	color:#000000;
	font-family:"Trebuchet MS";
	font-size:14px;
	text-decoration:none;
	}
#nav a:hover {
	text-decoration:underline;
	}
davidhowland14 is offline
Reply With Quote
View Public Profile Visit davidhowland14's homepage!
 
 
Register now for full access!
Old 04-01-2008, 06:13 PM Re: Vertical Centering
VirtuosiMedia's Avatar
Web Design Made Simple

Posts: 1,228
Trades: 0
Try playing around with your line height.
VirtuosiMedia is offline
Reply With Quote
View Public Profile Visit VirtuosiMedia's homepage!
 
Old 04-01-2008, 07:03 PM Re: Vertical Centering
Skilled Talker

Posts: 93
Name: David Howland
Location: New England
Trades: 0
No, line height won't help me. I'm trying to center the text within the nav bar area, and there is only one line of text.
davidhowland14 is offline
Reply With Quote
View Public Profile Visit davidhowland14's homepage!
 
Old 04-01-2008, 07:15 PM Re: Vertical Centering
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Quote:
No, line height won't help me. I'm trying to center the text within the nav bar area...
Yes it will. I use line height to vertically center text within nav bars (in fact this is the main method I use). You must set the height of the nav bar to be equal to the line-height of the text that must be aligned vertically. That is it! If you use proportional fonts (which I usually recommend), be sure to set both line-height and height in em, not px.
__________________
Join me on
Please login or register to view this content. Registration is FREE

Last edited by wayfarer07; 04-01-2008 at 07:16 PM..
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 04-01-2008, 09:48 PM Re: Vertical Centering
VirtuosiMedia's Avatar
Web Design Made Simple

Posts: 1,228
Trades: 0
Quote:
Originally Posted by davidhowland14 View Post
No, line height won't help me. I'm trying to center the text within the nav bar area, and there is only one line of text.
It doesn't hurt to try. It would only take about 30 seconds...
VirtuosiMedia is offline
Reply With Quote
View Public Profile Visit VirtuosiMedia's homepage!
 
Old 04-02-2008, 05:42 AM Re: Vertical Centering
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
vertical-align properties are only applied to inline elements within the same container.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Vertical Centering
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.22524 seconds with 12 queries