当前位置: 动力学知识库 > 问答 > 编程问答 >

html - targeting 'category' in css

问题描述:

My Wordpress site shows the post-title and category over-top the featured image.

I want to get the text to be #ffffff (white). I successfully targeted both in my css, but the 'category' doesn't change colour like the post-title did.

css

.title-styling {

width: 85%;

position: relative;

}

.title-styling h1 {

color: #fff;

font: 700 60px/50px "Open Sans";

}

.title-styling h2 {

color: #fff !important;

font: 500 15px/10px "Open Sans";

}

html

 <div class="box-title">

<div class="title-styling">

<a href="<?php the_permalink(); ?>" rel="bookmark"><h1><?php the_title(); ?></h1></a>

<h2 class="box-meta"><?php the_category(', '); ?></h2>

</div>

</div>

The text size and text-colour changed correctly for .title-styling h1 {

but only the text size changed for .title-styling h2 { (I tried with and without !important)

网友答案:

you can do one of the following:-

Remove class="box-meta" from the h2 tag

OR

Include a css class "box-meta" in your css file

网友答案:

I'm betting that the problem is the <h2> tag having a "More specific" class, try changing your CSS like this:

.title-styling > h2.box-meta {
    color: #fff;
    font: 500 15px/10px "Open Sans";
}
分享给朋友:
您可能感兴趣的文章:
随机阅读: