【问题标题】:How to design the link text color inside the div according to its class如何根据其类设计div内的链接文本颜色
【发布时间】:2020-01-02 16:28:00
【问题描述】:

已为所有链接设置了链接颜色和设计,但 div 内的链接未显示任何更改。

我想设计与管理员操作链接相对的摘录链接。表示背景颜色和白色文本。但是这里的背景颜色对文本颜色没有影响。我已经让它出现在白色文本中,但什么也没发生。

我可以使用类更改颜色,但不会使用类 a:link 此外,悬停也不起作用。

HTML

<div class="entry-content">
        <p>The standard Lorem Ipsum passage...<a class="more" href="#">Read the full article</a></p>
<span class="cat-links">Posted in <a href="#" rel="category tag">Design</a></span><span class="comments-link"><a href="#">Leave a Comment<span class="screen-reader-text"> on Lorem copied</span></a></span><span class="edit-link"><a class="post-edit-link" href="#">Edit <span class="screen-reader-text">Lorem copied</span></a></span>
</div>

CSS

.entry-content a.more:link {
    padding: 0px 5px;
    border-radius: 5px;
    border: 1px solid #17a2b8;
    background-color: #17a2b8;
    color: #ffffff;
}

如何将类用于链接颜色、背景颜色以及悬停时的更改...?

【问题讨论】:

  • 你能解释清楚..你不能改变哪种内容颜色?
  • 您发布的代码有效:jsfiddle.net/davidThomas/1dqxpkth,这意味着您还有一些其他的 CSS 规则,比这个更具体。找出可能是哪些规则,并降低它们的特异性或增加.entry-content a.more:link 选择器的特异性。

标签: html css colors hyperlink


【解决方案1】:

如果我理解正确:

.entry-content p {
/*whatever color you need for paragraph text*/
color: #000000
}

.entry-content a:hover {
/* whatever color you need for link hover */
color: #ffffff;
}

如果您需要为每个链接使用不同的颜色或悬停,您当然可以单独调用 span 类。不要忘记记住优先顺序。

【讨论】:

    猜你喜欢
    • 2020-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-14
    • 2012-05-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多