【问题标题】:Value from CSS root variable is not affecting on HTMLCSS 根变量的值不影响 HTML
【发布时间】:2020-12-19 11:21:29
【问题描述】:

我正在尝试在home.html 上设置文本颜色。颜色的属性在:root variable 中设置,但在 HTML 页面上不生效。

这是我的代码:

home.scss

:root {
--prim-headclr : #004c3f;
}

/* heading */
.phead_clr{
    color:var(--prim-headclr);
}

home.html

    <div class="col-md-12 phead_clr">
        <h1>Build an online business—no matter what business you’re in</h1>
    </div>

为什么根变量中的给定颜色对 HTML 端没有影响?

【问题讨论】:

  • phead_clr 类添加到 h1。

标签: html css typescript sass


【解决方案1】:

将此“phead_clr”类添加到 h1。

<div class="col-md-12">
    <h1 class="phead_clr"> build an online business—no matter what business you’re in</h1>
</div>

***如果css被其他变量或默认变量覆盖,那么你也可以添加important。

:root {
  --prim-headclr : #004c3f !important;
}

【讨论】:

    猜你喜欢
    • 2019-10-23
    • 1970-01-01
    • 1970-01-01
    • 2020-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多