I'm currently working on designing a stylish navigation bar using CSS, and I have a specific feature in mind. When a user hovers over a link in the navigation bar, I want a colored bar to appear under a different link. Essentially, I need the background color of one box to change when hovering over another.
Here's the HTML code:
<div id="navbar">
<div class="links">
<table>
<tr>
<td class="link1"></td><a href="Index.html">Calvin and Hobbes</a></td>
<td class="link2"><a href="Index.html">Garfield</a></td>
</tr>
<tr class="hoverbar">
<td class="link1hover"></td>
<td class="link2hover"></td>
</tr>
</table>
</div>
</div>
And here is the accompanying CSS styling:
.links {
float:right;
font-size:200%;
}
#navbar table{
margin-top:30px;
border-spacing:40px 0px;
}
#navbar td {
line-height:30px;
}
.hoverbar {
height:5px;
}
.link1:hover + .link1hover {
background-color:#FF5C00;
}
.link2:hover + .link2hover {
background-color:#FF5C00;
}
a:link {color:black; background-color:transparent; text-decoration:none}
a:visited {color:black; background-color:transparent; text-decoration:none}
a:hover {color:#FF5C00; background-color:transparent; text-decoration:none}
a:active {color:#FF5C00; background-color:transparent; text-decoration:none}