Home | Community | Message Board

Magic-Mushrooms-Shop.com
This site includes paid links. Please support our sponsors.


Welcome to the Shroomery Message Board! You are experiencing a small sample of what the site has to offer. Please login or register to post messages and view our exclusive members-only content. You'll gain access to additional forums, file attachments, board customizations, encrypted private messages, and much more!

Jump to first unread post Pages: 1
InvisibleOJK
Stranger
 User Gallery

Registered: 06/08/03
Posts: 10,629
How do php/CSS heirarchies work?
    #7443936 - 09/23/07 12:17 PM (16 years, 4 months ago)

Hey,

I'm trying to apply some presentation-fu to a Wordpress theme that I'm using.

Specifically, I'm trying to get a "Recent Posts" widgit to display its links in a specific colour to tie in with the look of the rest of the site.

I've edited the php of the widgit to read:
Code:
//output to screen
echo '<li>
<div class="recentpost"><a class="post" rel="bookmark" href="'.get_permalink($post->ID).'"><span class="inner">
<strong class="title lifestyle">'.$post->post_title.'</strong></div>';

if ($excerpt) echo '<br />'.strip_tags($post->post_excerpt);

echo '</span></a><br /></li>';



So that it applys the class "recentpost" to the links it generates.

I've then edited the main stylesheet for the site to read:
Code:
.recentpost {
color:#3DF500;
}
.recentpost a:hover {
text-decoration: underline;
color:#3DF500;
}



Now, the text-decoration works fine - the links turn underlined when they are hovered over. However, the colour doesn't have any effect - the links are still the default stylesheet colour.

Because the stylesheet ships with the theme I'm modifying, I'm not hugely familiar with it, and I don't really want to edit different parts of it in case it borks things horribly.

I think that the color setting isn't having any effect because another part of the stylesheet is "overriding" the color I'm trying to set - how do hierarchies of this sort work in CSS? Can I get the links to display in that color without editing different parts of the stylesheet?

Thanks :sun:


Edited by Odiumjunkie (09/23/07 01:02 PM)


Extras: Filter Print Post Top
InvisibleOJK
Stranger
 User Gallery

Registered: 06/08/03
Posts: 10,629
Re: How do php/CSS heirarchies work? [Re: OJK]
    #7444026 - 09/23/07 12:55 PM (16 years, 4 months ago)

I managed to find the answer to my own question: CSS specificity.

I fixed my CSS problem by increasing the specificity of the commands, so the browser would interpret them as more important:
Code:
body li #recentpost .recentpost2 {
color:#3DF500;
}
body li #recentpost .recentpost2 a:hover {
text-decoration: underline;
}
body li #recentpost .recentpost2 a:visited {
color:#999;
}
body li #recentpost .recentpost2 a {
color:#3DF500;
}



Edited by Odiumjunkie (09/23/07 01:01 PM)


Extras: Filter Print Post Top
OfflineYthanA
ᕕ( ᐛ )ᕗ
Male User Gallery


Registered: 08/08/97
Posts: 18,774
Loc: NY/MA/VT Borderlands Flag
Last seen: 1 hour, 30 minutes
Re: How do php/CSS heirarchies work? [Re: OJK]
    #7446135 - 09/23/07 11:01 PM (16 years, 4 months ago)

Glad you figured it out, don't forget about the !important flag as well. :smile:


Extras: Filter Print Post Top
Jump to top Pages: 1


Similar ThreadsPosterViewsRepliesLast post
* HTML/CSS question dirtworshipper 608 2 01/24/22 05:46 PM
by SprewellSleeve
* php easter egg Mycomancer 5,143 7 05/02/06 03:15 AM
by Le_Canard
* html tables vs css daytripper05 1,164 6 04/08/07 03:56 AM
by Seuss
* ATTN: PHP/MySQL Gurus
( 1 2 all )
elbisivni 2,075 20 09/04/07 06:04 PM
by elbisivni
* Shroomery CSS BUDDHA_702 1,026 11 11/08/07 01:11 PM
by jeetered
* MSIE CSS 2.0 Compliance Issues: Variance Torn For Kaputtzville... PapaverS 995 8 06/17/06 01:43 AM
by Papaver
* Halp with CSS plzords Gravija 345 3 06/01/12 02:32 PM
by Gravija
* CSS Drop Down Menu daytripper05 818 4 07/24/08 11:42 AM
by RoosterCogburn

Extra information
You cannot start new topics / You cannot reply to topics
HTML is disabled / BBCode is enabled
Moderator: trendal, automan, Northerner
561 topic views. 0 members, 0 guests and 2 web crawlers are browsing this forum.
[ Show Images Only | Sort by Score | Print Topic ]
Search this thread:

Copyright 1997-2024 Mind Media. Some rights reserved.

Generated in 0.024 seconds spending 0.007 seconds on 14 queries.