I’ve got a tricky problem trying to position an image on an active menu item on wordpress. The html is spat out by wordpress so I can’t change the classes I’m presented with I’ve managed to create a nice flexible menu but I can’t seem to get control over the positioning of this image.
This is what I’m trying to achieve > http://i48.tinypic.com/1pyzqo.png
Below is the HTML and here is a fiddle > http://jsfiddle.net/rafoggin/cwA7Y/1/
HTML:
<nav id="navigation" class="menu-main-navigation-container">
<ul id="main-menu" class="item-list inline links small">
<li id="menu-item-54" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-54"><a href="http://richardfoggin.co.uk/pinkfloyd/about">About</a></li>
<li id="menu-item-57" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-55 current_page_item menu-item-57"><a href="http://richardfoggin.co.uk/pinkfloyd/">Portfolio</a></li>
<li id="menu-item-42" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-42"><a href="http://richardfoggin.co.uk/pinkfloyd/blog">Blog</a></li>
</ul>
</nav>
And the CSS:
nav#navigation {
position:absolute;
top:0; width:100%;
padding:20px 0 0;
border-bottom:1px solid #dedede;
background: #FFFFFF;
}
nav#navigation ul#main-menu {
list-style-type: none;
width: 100%;
margin-left: auto;
margin-right: auto;
text-align: center;
}
nav#navigation ul#main-menu li{
display: inline-block;
}
nav#navigation ul#main-menu a{
display: block;
text-decoration: none;
color: black;
padding: 8px;
margin: 0 9px;
}
li.current_page_item a {
background: url(http://richardfoggin.co.uk/pinkfloyd/wp-content/themes/svbtle/images/menu-bg.png) no-repeat 50% 100%;
border-bottom: solid 1px #fff;
}
I’ve tried a :after pseudo-element on the li.current_page_item a class but this didn’t hit the mark. But stuck about how to do this, any help would be much appreciated as always 🙂
R
You can use
:after, but you need to combine it with absolute positioning. You also need to give this positioned item a size.