Dax
Dax

Reputation: 25

Button Image on Current Page

I currently have image-links on my navbar, as well as additional images for when you're hovering over the link. I would like to know the best way to set it so the current page a user is on shows a third image.

For example, user is on index.html, which would be Home on the navbar, so I would like Home to be a different image than About, Contact, etc. This is my current HTML and CSS.

<ul id="navbar">
    <li id="bf"><a class="button" href="index.html">Home</a></li>
    <li id="bf"><a class="button" href="about.html">About Us</a></li>
    <li id="bf"><a class="button" href="contact.html">Contact</a></li>
    <li id="bf"><a class="button" href="images.html">Images</a></li>
</ul>
#navbar {
    left:50%;
    margin-left:325px;
    top:50%;
    margin-top:-100px;
}

#bf {
    display:inline;
}

a.button {
    display: -moz-inline-stack;
    display: inline-block;
    width: 147px;
    height: 49px;
    background: url("/images/btn.png") no-repeat;
    line-height: 43px;
    vertical-align: text-middle;
    text-align: center;
    color: #180a6b;
    font-family: Verdana;
    font-size: 25px;
    font-weight: normal;
    font-style: normal;
    text-shadow: #FFFFFF 1px 1px 0;
    text-decoration: none;
}

a.button:hover {
    background: url("/images/hovbtn.png") no-repeat;
    color: #8d8fc2;
}

Upvotes: 0

Views: 1079

Answers (1)

dinodsaurus
dinodsaurus

Reputation: 5095

just add a class active to a list item/link and then style it. U could use it like this:

<ul id="navbar">
<li id="bf"><a class="button active" href="index.html">Home</a></li>
<li id="bf"><a class="button" href="about.html">About Us</a></li>
<li id="bf"><a class="button" href="contact.html">Contact</a></li>
<li id="bf"><a class="button" href="images.html">Images</a></li>
</ul>

and then style it

#navbar li a:hover{
    background:red;
}
#navbar li a.active {
    background:yellow;
}

Upvotes: 1

Related Questions