开发者

HTML/CSS - give li class

Just trying to get the (.portfoliocategs) category menu on this site to have a different colour highlight for each li.

[link to website in below comment]

As you can see at the moment they're all blue. I would like to be able to specify either a class or colour for each category li listed.

Any ideas on how this could be done?

EDIT: This is the code for the category menu - I'm not sure how to add a CSS class to each seperate category as it seems to grab "all categories" from the php??

<?php  if(is_category() && in_category($current_id) || post_is_in_descendant_category($current_id)){?>
    <h1 style="display:none"> <?php single_cat_title(); ?> </h1>

    <ul class="portfolioCategs">
        <li><a href="<?php echo get_cat开发者_Go百科egory_link(get_option('boldy_portfolio'))?>">All projects</a></li>

$categories = get_categories('hide_empty=1&child_of='.$categs); foreach ($categories as $cat) { echo "".$catname."\n"; echo ('cat_ID).'">'.$cat->cat_name.''); } ?>


We are talking just CSS right?

Something like this?

ul.portfolioCategs li a.cat3:hover {background-color: #660099; }
ul.portfolioCategs li a.cat13:hover {background-color: #CC3300; }
ul.portfolioCategs li a.cat14:hover {background-color: #FF6600; }
ul.portfolioCategs li a.cat17:hover {background-color: #FF6666; }
ul.portfolioCategs li a.cat19:hover {background-color: #FF6699; }
ul.portfolioCategs li a.cat20:hover {background-color: #FF66CC; }
ul.portfolioCategs li a.cat21:hover {background-color: #FF66FF; }

Just remove the :hover if you want a constant background.

Make sure the link tag has the corresponding category.

<a class="cat13" href="http://www.some-things.net/?cat=13">Fashion</a>

PS. dont' tag this as PHP and Wordpress when it's only CSS and HTML :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜