Menu Items
Posted: 07 August 2008 08:02 PM   [ Ignore ]
Newbie
Rank
Total Posts:  6
Joined  2008-03-20

I’m trying to wrap my mind around how to make “pill capsules” behind links (active and hover).  Of course using UL and LI’s I know how to make a menu and I even know how to have a background image show up in the CSS under the active link.  But I’m trying to have a left and right (start and finish of the capsule) so that no matter how big the text the effect will have the same amount of space on both sides (centering the text between the ends).

This is what I have so far:

<div id="menu1">
<
ul>
   <
li><a href="#">Home</a></li>
   <
li><a href="#">Profile</a></li>
   <
li><a href="#">Blog</a></li>
   <
li><a href="#">Contact</a></li>
</
ul>  
</
div>

#menu1{
    
height:25px;
    
font-family:VerdanaArialHelveticasans-serif;
}
#menu1 ul{
    
margin:0;
    
padding:0;
    list-
style-type:none;
}
#menu1 ul li{
    
display:inline;
}
#menu1 ul li a{
    
text-decoration:none;
    
float:left;
    
height:25;
    
margin:12px 0;
    
padding:15px;
    
width:65px;
    
text-align:center;
}

#menu1 a:link, #menu1 a:visited{
    
color:#fff;
    
background-image:url(images/link.gif);
    
background-repeat:repeat-x;
    
background-position:center;
}
#menu1 a:hover, #menu1 a:active{
    
color:#000;
    
background-image:url(images/hover.gif);
    
background-repeat:repeat-x;
    
background-position:center;

Please help!!!

Profile
 
 
Posted: 07 August 2008 11:58 PM   [ Ignore ]   [ # 1 ]
Newbie
Rank
Total Posts:  4
Joined  2008-08-07

From what I have read in your forum post you are wanting to have a CSS rollover effect on the hover state, plus have the background image of each link grow and shrink to match the width of each menu item. To achieve this menu style you will have to put <span> tags around your link text. This will allow you to have a ‘cap’ image for the a: link and a ‘cap’ image for the <span> tag. Here is an example of what I use for this menu style:

CSS Code

#navbar li a, ul.menu li a:visited {text-decoration: none; display: block; height: 32px; margin: 8px 10px 20px 0; padding: 0 0 0 10px; background: url(../images/capLeft.png) no-repeat top left; color: #fff;}

#navbar li a span {display: block; padding: 8px 15px 8px 0; background: url(../images/capRight.png) no-repeat top right;}

#navbar li a:hover, #navbar li a:active {background: url(../images/capLeft.png) no-repeat bottom left; color: #fff;}

#navbar li a:hover span, #navbar li a:active span {background: url(../images/capRight.png) no-repeat bottom right; color: #fff;}

#navbar li.active a, #navbar li.active a:visited {background: url(../images/capLeft.png) no-repeat bottom left; color: #fff;}

#navbar li.active a span, #navbar li.active a:visited span {background: url(../images/capRight.png) no-repeat bottom right; color: #fff;}

#navbar li.active a:hover span, #navbar li.active a:active span {background: url(../images/capRight.png) no-repeat bottom right; color: #fff;} 

XHTML Code

<ul class="menu">
<
li id="current" class="parent active item1"><a href="http://www.imaginemediadesigns.com/learnthecms/"><span>Home</span></a></li>
<
li class="parent item55"><a href="/learnthecms/index.php/the-cms.html"><span>The CMS</span></a></li>
<
li class="parent item56"><a href="/learnthecms/index.php/features.html"><span>Features</span></a></li>
<
li class="parent item57"><a href="/learnthecms/index.php/extensions.html"><span>Extensions</span></a></li>
</
ul

Hope this helps you out!

Profile