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
Problem with CSS menu text/image
Old 12-10-2007, 09:33 AM Problem with CSS menu text/image
Extreme Talker

Posts: 188
Trades: 0
I have been designing my new site over the last few days and have just come to write the XHTML and CSS. The problem being I want the menu across the screen in text with an image as a divider. the only problem is the text defaults to the bottom of the image, where I want it in the middle.

I have tried vertical-align but this just puts it to the top or doesn't move it at all. Any ideas?

http://3sky.eu/

(the menu is in a separate .php file)

PHP Code:
<div id="menu">
<
ul>
<
li><a href="index.php"HOME </a><img src="images/spliter.jpg"></li>
<
li><a href="tvshows.php"TV SHOWS </a><img src="images/spliter.jpg"></li>
<
li><a href="films.php"FILMS </a><img src="images/spliter.jpg"></li>
</
ul>
</
div
The CSS file

Code:
#menu {
    clear: both;
    list-style-image: none;
    list-style-type: none;
    width: 770px;
    margin-right: auto;
    margin-left: auto;
    margin-top: -12px;
}

#menu li {
    font-family: Tahoma;
    font-size: 18px;
    color: #000000;
    text-decoration: none;
    list-style-image: none;
    list-style-type: none;
    float: left;
}

#menu li a {
    text-decoration: none;
    color: #000000;
    padding-right: 20px;
    padding-left: 20px;
    padding-top: -15px;
}

#menu li a:hover {
    color: #FFFFFF;
}
__________________

Please login or register to view this content. Registration is FREE
twiggy is offline
Reply With Quote
View Public Profile Visit twiggy's homepage!
 
 
Register now for full access!
Old 12-10-2007, 09:42 AM Re: Problem with CSS menu text/image
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
determine the height of the image in pixels, then set the height and line-height of the text to that exact pixel amount:

an example:

menu li a {
display: block;
height: 25px; /*however tall the image is*/
line-height: 25px;
}
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 12-10-2007, 09:48 AM Re: Problem with CSS menu text/image
Super Moderator

Posts: 1,576
Location: Kokkola, Finland
Trades: 1
that doesn't work if you resize the text in via the browser
davemies is online now
Reply With Quote
View Public Profile Visit davemies's homepage!
 
Old 12-10-2007, 10:23 AM Re: Problem with CSS menu text/image
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
To be honest, twiggy, I think you have the wrong approach here. If it was me , I would be placing the image as a background to the link, using background positioning a block display to give me better control over the link. There are about a hundred different ways to approach this problem. The usual solution to getting text to vertically center over a block-type element is to set height and line-height to the same amount.
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 12-10-2007, 11:16 AM Re: Problem with CSS menu text/image
Extreme Talker

Posts: 188
Trades: 0
The line-height trick worked for the text but now the images have moved down. Any ideas?

Take a look at http://www.3sky.eu
__________________

Please login or register to view this content. Registration is FREE
twiggy is offline
Reply With Quote
View Public Profile Visit twiggy's homepage!
 
Old 12-10-2007, 11:21 AM Re: Problem with CSS menu text/image
Extreme Talker

Posts: 188
Trades: 0
I have decided to not have any dividers now, causing to many problems. Thanks for your help any way.
__________________

Please login or register to view this content. Registration is FREE
twiggy is offline
Reply With Quote
View Public Profile Visit twiggy's homepage!
 
Old 12-10-2007, 12:22 PM Re: Problem with CSS menu text/image
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
vertical-align only applies to inline elements, li's are block

Set the li height to the image height, float the image right, put the anchor in a span inside the li and use vertical-align:middle for the anchor, set the font-size of the span to the image height in pixels, and set the font-size of the anchor to 1/5 the span text height.

__________________
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 Problem with CSS menu text/image
 

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.58876 seconds with 12 queries