Results 1 to 2 of 2

Thread: Changing bg-color of Menu's on clicking

  1. #1
    Join Date
    Jul 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Changing bg-color of Menu's on clicking

    Hi,

    I'm looking for a CSS/JavaScript solution for changing the color of a menu item on clicking.

    I already have a menu created using CSS.

    It is displayed in a DIV with "a:hover" style defining what color the menu item should be displayed in, when the "mouse over" event occurs.

    Now, I want the color of the menu item to change when the user selects that menu item. I cannot use a:visited, because each menu item displays a different page, and ONLY the menu item selected, must display YELLOW background to indicate that the user is on that page. Any generic CSS/JavaScript code will be greatly appreciated.

    Thanks
    Ahi

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    You could make a class called 'current', then use the following for the css:

    Code:
    .current {
    background-color: yellow; /* the background color */
    color: black; /* the font color */
    }
    then for the html in the menu (sample, not exactly your menu because you did not post the code for it):

    Code:
    <div class="current">
    Place that for the link that corresponds to the page that it references.

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •