如何定位h2内的元素

时间:2011-03-15 06:24:47

标签: css

我无法弄清楚如何在css中设置H2链接的样式。我已经尝试了一切。我如何定位h2元素中的链接?

<div id="post-225" class="post-225 post type-post sticky hentry category-rugby-world-cup tag-land-rover-rugby-world-cup-2011-rugby-world-cup-2015-land-rover-rugby">
    <h2><a href="http://blog.landrover.com/events/rugby-world-cup/england-rugby-squad-vs-media-driving-challenge-day" title="Permalink to England Rugby Squad vs. Media Driving Challenge Day" rel="bookmark">England Rugby Squad vs. Media Driving Challenge Day</a></h2>

我需要将这篇粘贴帖子的标题设为白色:

http://blog.landrover.com/

我尝试过.sticky h2 a {color:white;}但没有成功。

非常感谢任何帮助。

由于

3 个答案:

答案 0 :(得分:4)

您的.sticky h2 a {color:white;}被主要样式覆盖:

#content h2 a {
color: #4C4C4C;
}

要定位粘性类的特定h2,请使用:

#content .sticky h2 a{
color:#fff;
}

答案 1 :(得分:0)

您也可以这样做

#content .sticky h2 a { color: #fff; }

答案 2 :(得分:0)

有人事先尝试过这些建议吗?似乎没有什么对我有用,因为网站上的字体替换无法正常工作。我在Chrome 11中收到Resource interpreted as Font but transferred with MIME type font/woff.错误。如果修复了这一点,只需添加

即可
.sticky h2 a {
    color: #fff !important;
}

应该有用。