Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS a:active help

  • This topic is empty.
Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #43956
    iamRDM
    Participant

    Hey guys i need some help with a:active
    what i want is the link of active page should stay of other color when we open it
    this is my html for menu

    `

    `

    and css

    a:link {
    color: #42413C;
    text-decoration: none;
    }
    a:visited {
    text-decoration: none;
    }
    a:hover{
    text-decoration: none;
    }
    a:active {
    color:#424242
    text-decoration: none;
    }
    #menu
    {
    width:100%;
    height:40px;
    margin: 0 auto;
    padding:12px 0 0 0;
    }
    #menu a{
    margin-left:20px;
    margin-right:20px;
    font-size:15px;
    color:#fff;
    }
    #menu a:hover{
    color:#81a34c;
    text-decoration:underline;
    }

    the active only stays when we click on the link as we remove the mouse click it changes back to normal

    #130989
    Paulie_D
    Member

    >the active only stays when we click on the link as we remove the mouse click it changes back to normal

    That’s what `:active` is supposed to do.

    #130990
    pixelgrid
    Participant

    the :active state is an event that fires when you press a link.it last until you release the mouse ,what you need is to make the document enter a class for you depending on the page you are currently viewing

    #130994
    Paulie_D
    Member

    If you have only a few pages the simplest method is to give each separate page an id like

    then add classes to each of the links

    `

    `

    Then you can target them with

    #home a.home {
    color: anything;
    }

    #contact a.contact {
    color: anything;
    }
    If you see what I mean.

    #130995
    iamRDM
    Participant

    How to make it to stay ?

    #130998
    yoyo
    Participant

    [this example](http://www.hicksdesign.co.uk/else/cssnav/ ) might help you

    #131000
    Paulie_D
    Member

    @yoyo Good link.

    I probably would go with classes on the links but IDs work as well.

    #131002
    iamRDM
    Participant

    for #home a.home {
    color: red;
    }
    it worked
    but on other pages Home is still red not the page which we opened

    #131003
    Paulie_D
    Member

    Do you have a link?

    It sounds like you haven’t set it up correctly.

    #131004
    iamRDM
    Participant

    here it is http://srepacks.com

    #131008
    Paulie_D
    Member

    Yeah…you haven’t given the pages different IDs.

    You need to do that then:

    #home a.home,
    #products a.products,
    #contact a.contact {
    color: red;
    }

    #131011
    iamRDM
    Participant

    @Paulie_D Thanks a lot for your time :)
    Because of you guys i finally learnt this today :D
    I’m loving css-tricks and people here :D

    @Paulie_D
    I guess this is the 4th or 5th timr you have helped me here, really appreciate your help

Viewing 12 posts - 1 through 12 (of 12 total)
  • The forum ‘CSS’ is closed to new topics and replies.