- This topic is empty.
-
AuthorPosts
-
April 8, 2013 at 7:29 am #43956
iamRDM
ParticipantHey 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
April 8, 2013 at 7:35 am #130989Paulie_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.
April 8, 2013 at 7:37 am #130990pixelgrid
Participantthe :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
April 8, 2013 at 7:40 am #130994Paulie_D
MemberIf 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.April 8, 2013 at 7:41 am #130995iamRDM
ParticipantHow to make it to stay ?
April 8, 2013 at 7:47 am #130998yoyo
Participant[this example](http://www.hicksdesign.co.uk/else/cssnav/ ) might help you
April 8, 2013 at 7:49 am #131000April 8, 2013 at 7:50 am #131002iamRDM
Participantfor #home a.home {
color: red;
}
it worked
but on other pages Home is still red not the page which we openedApril 8, 2013 at 7:58 am #131003Paulie_D
MemberDo you have a link?
It sounds like you haven’t set it up correctly.
April 8, 2013 at 8:08 am #131004iamRDM
Participanthere it is http://srepacks.com
April 8, 2013 at 8:17 am #131008Paulie_D
MemberYeah…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;
}April 8, 2013 at 8:27 am #131011 -
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.