Home
PDF Print E-mail
Written by Administrator   
Thursday, 18 February 2010 23:22

How to create rollover image menu in WordPress, without any plugins?

Ok, first of all You need to create menu page links:

  1. Log in to the WP admin panel: http://YourSite.com/wp-admin/
  2. Click on Pages from left panel then Add New:
    create rollover image menu in WordPress
  3. Create pages for example: Home, Services, Portfolio, Blog, Contact
  4. Next from the left navbar click on Appearance - Widgets:
    create rollover image menu in WordPress
  5. Move Pages from Available Widgets to your Sidebar:
    create rollover image menu in WordPress

Now we have to create rollover image menu. In Photoshop i created images for our menu:
I have two images with height 36px each:

create rollover image menu in WordPress

Now we have to unite this two images in one with height 72px:

create rollover image menu in WordPress

As You can see this image is combination of two images with height:  36px + 36px.

Next we have to add some styles to our CSS file. Connect to the ftp and open file style.css from folder: /wp-content/themes/YourTheme/

Every menu in WP has an unique class: page-item-14, page-item-41, so we will add this code:


#sidebar .page-item-41 {
height: 36px;
width: 174px;
display: block;
}
#sidebar .page-item-41 a {
background: url(images/services-btn.png) 0 0 no-repeat;
width: 174px;
height: 36px;
display: block;
text-indent: -9999px
}
#sidebar .page-item-41 a:hover {
background-position: 0 -36px
}

What in this code:

#sidebar .page-item-41 a
height: 36px - this is half of our image height (important)
background: url(images/services-btn.png) 0 0 no-repeat  - our image background with background position left: 0 top:0

#sidebar .page-item-41 a:hover
background-position: 0 -36px - we added negative position of image background top: -36px

 

Here what we got:

 

 

Or You can see a live WP site with this menu: http://webvine.com.au/

OK, if You have any questions leav me a comment

-------

How to add active menu style for WP menu

When you click on site menu, the active menu adding new class:


<li class="current_page_item"><a href="#">Active Menu</a></li>

So to adding CSS style effect to Active menu you should add at the bottom of your CSS file this code:


#sidebar .current_page_item a {background-position: 0 -36px}

 

Thx, Vlad


Last Updated on Tuesday, 14 December 2010 16:15
 

Comments 

 
#1 2010-11-10 14:43
I've used roll over images for wordpress menus for a while, but I am stuck with making a image for the menu link that is active. The wordpress menu doesn't seem to recognize the active page and reverts the menu link back to passive style when using this effct. Have you succeeded in using a #sidebar .page-item-41 a:active approach?
Quote
 
 
#2 2010-11-10 23:35
I updated this article and i hope it will help you.

If you still have a problem, send me message by contact form, i'll help you with your problem :)
Quote
 
 
#3 2010-11-27 14:25
but you should have few differents active-btn.png files for different pages. how to write it in css so wp would understand when to use service-active.png and when to use home-active.png

Works perfect here - http://webvine.com.au/ but I just don't get how to do the same.
Quote
 
 
#4 2010-12-14 16:47
I updated article again, so active menu will be the same as HOVER menu...

Thx,
Vlad
Quote
 
 
#5 2010-12-23 16:03
Thnx for this tutorial! great help, but i've got a problem with showing the menu's active page.

i can't see where to put in

Active Menu

i only have



in my php page.

isn't it possible to solve this through css, the way you did with a:hover? I don't understand why a:active isn't working.
Quote
 
 
#6 Jen 2011-04-26 05:42
Your tutorial is great, and I'm so grateful to have found it.

I'm having trouble seeing how to implement these styles into my sidebar html list code in Wordpress. You did share the following code:
Quote:
Active Menu


But I'm not sure to implement this into my list of menu items. Could you please give me a better idea of how this works in the WP sidebar.php file?
Quote
 

Add comment


Security code
Refresh

© 2010. Sopov.com