Reputation: 23
My question is :
I have a menu items, and I want to highlight the active tab that users switch to that points to another page for sure .
stackover flow use :
.nav {
float: left;
font-size: 125%;
}
.nav ul {
margin: 0;
}
.nav li {
background: none repeat scroll 0 0 #777777;
display: block;
float: left;
margin-right: 7px;
}
**.nav .youarehere {
background: none repeat scroll 0 0 #FF9900;
}**
.youarehere a {
color: #FFFFFF;
}
.nav li:hover {
background-color: #FF9900;
}
.nav a {
color: #FFFFFF;
display: block;
padding: 6px 12px;
text-decoration: none;
}
Can anybody tell me what else they use to make this work ?
Upvotes: 1
Views: 1889
Reputation: 15909
Well one way to do it with Javascript that I've used before on my pages,
Put all of your sidebar buttons in a CSS class called sideBarButton. activeSideBarButton will be a class that gets set when the link is the same as the current window's location.
$(document).ready(function () {
var sideBarButtons = $(".sideBarButton");
for(var i in sideBarButtons)
{
if(!sideBarButtons[i].pathname)
{
continue;
}
if(sideBarButtons[i].pathname == window.location.pathname)
{
sideBarButtons[i].className += ' activeSideBarButton';
console.log("Enabled button " + sideBarButtons[i]);
}
}
});
Upvotes: 2