- This topic is empty.
-
AuthorPosts
-
December 15, 2011 at 2:17 pm #35671
CassieNoelPhoto
MemberI’m trying to figure out how to change the color of my link when you are on that certain page. For example, the text is always gray, but when you are on the about page the about button will be blue.
Thank you for your help!
December 15, 2011 at 2:29 pm #92851TheDoc
MemberIs this a static site? Is this a WordPress site?
Either way, you’ll need a different class to be applied to your link. Most people like “current” or something similar. Then with CSS you can apply a different style to it! Do you have a link to the site in question? People can give you very specific answers if that’s the case!
December 15, 2011 at 3:33 pm #92854snillor
MemberThere are several ways to do this; what TheDoc says is probably the simplest.
One other thing to consider: it’s never made sense to me to have a functioning link to the page you’re already on. So I usually remove the “home” link on the home page, the “about” link when on the about page, and so on. Usually the links (and these “non-links”, to which I give a class of “URhere”), are list items in an unordered list. I simply style the links as I want, and the URhere class differently to indicate that it’s not a link so don’t bother clicking. Depending on the color scheme, I style URhere darker or lighter or grayer or less saturated – whatever makes it less conspicuous.
December 15, 2011 at 4:21 pm #92856TheDoc
MemberI actually prefer the opposite method. I would rather make it more clear to the user what page they are on.
December 15, 2011 at 4:56 pm #92857December 15, 2011 at 5:00 pm #92858chauger
MemberJust another approach:
Base Styles
a {color: #ccc;}About Page Styles
.aboutPage a {color: #003399;}On your about page body add a class “aboutPage” so you can scope anything else you want to be different (links, margins, padding, etc…)
Whatever
Chris posted a link above that explains this in more detail. Though he used the “id” this will give you higher specificity than the class I used. The id may limit your flexibility a little.
Specificity Rules:
Chris has information on this too. You may want to take a look at that too.
https://css-tricks.com/specifics-on-css-specificity/Most to>>>>>>>>>>>>>>>>>>>>>>>>Least Specific
Style Attributes, ID, Class/Psuedo-Class/Attributes, ElementsChris’ Specificity: 0,1,0,1 (higher)
My Specificity: 0,0,1,1 (lower)Hope this helps.
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.