【问题标题】:Can't get my text colours to change in print css无法在打印 css 中更改我的文本颜色
【发布时间】:2012-08-27 07:47:26
【问题描述】:

我有一个在打印时需要一些自定义格式的 drupal 页面,所以我把它全部放在一个单独的打印 css 中。除了我的文本颜色之外,大部分都可以正常工作。

我已经尝试了所有与文本相关的选择器,甚至是*-selector。但它们都没有改变颜色。

起作用的是在我的真实页面上更改 Firefox 编辑器中的颜色。

HTML的一部分,这种情况下最里面的元素需要改成黑色:

<div class="field-label">Productgroep:&nbsp;</div>
     <div class="field-items">
          <div class="field-item even">
               <a href="/taxonomy/term/43" typeof="skos:Concept" property="rdfs:label skos:prefLabel">Fruit</a>
         </div>
     </div>
</div>

我试过的 CSS:

art-post-inner art-article, /* one of the wrappers */
field-items, /* the outer div */
a, /* select all links, I have also tried all the different states of a link (hovered, visited, etc) */
* /* select all */
{
    color: #000;
}

如果您需要更多信息,请尽管询问。

【问题讨论】:

  • 已尝试添加 !important 类似颜色:#000 !important;
  • 我从未听说过 !important 关键字。但它有效!请添加它作为答案,所以我可以接受它:)
  • 祝你好运,我加了

标签: html css colors


【解决方案1】:

试试!importantcolor: #000 !important;

它的作用

标记为 !important 的 CSS 规则优先于后面的规则。通常在 CSS 中,规则是从上到下工作的,因此如果您将新样式分配给样式表下方或辅助样式表中的元素,则后面的规则将优先。 !important 确保此规则具有优先权。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-02-22
    • 1970-01-01
    • 1970-01-01
    • 2017-03-12
    • 2011-02-01
    • 2012-03-25
    • 1970-01-01
    相关资源
    最近更新 更多