HomeWordpress → WordPress Navigation- Dropdown Menu Image

WordPress Navigation- Dropdown Menu Image

Having just updated my theme to make use of the WordPress navigation menus I decided I wanted to have a indicator to display that there is a drop down menu. This can be done many ways with plugins etc but I wanted to do it without the need of a plugin. So I had a think and came up with this idea which requires very little knowledge to carry out.

Create a Image

To start this tutorial off we need a image. The source files are available to download at the bottom of this post. I used Inkscape which I used for this particular project but you can use any other software. I first created a triangle and then I scaled it down to 15px by 8px. I placed the triangle hard to the left and left some space to the right. This stops the image from being pushed to the edge of the container which improves it’s appearance and prevents us from adding any padding to our CSS which may destroy the look.

Enable Hidden Options

Go to the WordPress admin and click on Appearance and then click on the Menus.

Hidden Options

Go to Screen Options and check the CSS Classes checkbox.

Inside Screen Options

Back in the menu section in my case I have Tutorials as a parent and the children are Windows, PHP and Linux.

Inside Menus

Expand tutorials by clicking on it and type drop-down into the CSS classes input box. Save your menu!

Expand Tutorials

Add the CSS

We of course now need add a few lines to your stylesheet. Open style.css in your favourite editor and enter the following

1
2
3
4
li.drop-down a
{
    background:url(images/down_arrow_8.png) no-repeat center right;
}

If you refresh your browser you may see that multiple images are being displayed like so.

Add a little CSS

To prevent this we add the following to the stylesheet.

1
2
3
4
#menu-navbar .sub-menu .menu-item a  , #menu-navbar .sub-menu .menu-item a:visited
{
    background-image: none;
}

Conclusion

Just a little more CSS

As you can see with the above image the extra images have disappeared. Hope you have enjoyed this simple tutorial and please feel free to contact me if you are experiencing any problems as not all navigation menu’s are the same so there maybe a little tweaking required.

Download

Share

Enjoyed this article? Then recommend it to your friends

               

One Response to “WordPress Navigation- Dropdown Menu Image”

  1. pedestrian passing by

    Thank you!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

* Copy this password:

* Type or paste password here:

4,945 Spam Comments Blocked so far by Spam Free Wordpress

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>