I’m using a ul navigation for my own personal site, but I can’t for the life of me figure out how to change the background-color of the whole li element. If you look at this fiddle, you can see what I’m trying to accomplish. I’ve looked everywhere, but I haven’t found a solution to “highlight” the area to the left of the text. Additionally, I am not sure how to account for the margin: 2px. Here is some relevant CSS:
#nav li {
margin:2px;
}
#nav li:hover {
margin:2px; <-- does not affect where the background color changes, it seems
background-color:#b5aec8;
}
Is there a way to change the entire nav background using pure CSS? If so, how? Any suggestions are appreciated!
From your fiddle, simply remove the padding from the
<ul>element and give it to the<li>elements, which will then be colored fully.See The Example Here.