I have some navigation elements in a <ul>
on the sidebar of my website. Here's the relevant markup and CSS styling:
<ul>
<li><a href="">Blog</a></li>
<li><a href="">Work</a></li>
<li><a href="">About</a></li>
<li><a href="">Contact</a></li>
</ul>
#sidebar ul {
list-style-type: none;
float: right;
position: relative;
right: -10px;
}
#sidebar ul li a {
display: inline-block;
line-height: 30px;
text-decoration: none;
padding: 0px 10px;
color: #555555;
}
#sidebar ul li a:hover {
background: url('images/nav-hover.png') no-repeat;
color: #f0f0f0;
}
When the user hovers over a navigation element (the <a>
tag) I want the background nav-hover.png
to slide in from the right using CSS transitions. I tried this but it doesn't seem to work:
#sidebar ul li a {
background: none;
transition-property: background;
transition-duration: 1s;
display: inline-block;
line-height: 30px;
text-decoration: none;
padding: 0px 10px;
color: #555555;
}
#sidebar ul li a:hover {
background: url('images/nav-hover.png') no-repeat;
color: #f0f0f0;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
How can I get this to happen?
JSFiddle link: http://jsfiddle.net/2EfYa/