【问题标题】:Bootstrap button color is not changing even by adding a css file and linking with html file?即使通过添加 css 文件并与 html 文件链接,引导按钮颜色也不会改变?
【发布时间】:2018-05-03 22:32:41
【问题描述】:

我从引导程序中添加了一个按钮代码,如下所示:

<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#exampleModal">
  Start Javascript
</button>

由于此代码按钮颜色为红色,我想将其更改为橙色,因为我添加了一个 css 文件并将其与 html 链接,如下所示:

.btn btn-danger {
    background-color: orange;
}

但按钮的颜色仍然是红色的橙色

【问题讨论】:

  • .btn.btn-danger { background-color: orange;}
  • 我可以工作,但为什么要多加一个点?
  • .btn btn-danger { background-color: orange !important;} 并确保在 boostrap.min.css 文件之后加载 css 自定义文件
  • @HT 点是为给定类选择的 css 选择器。所以.btn.btn-danger 将选择同时具有btnbtn-danger 类的任何元素。您可能只需选择.btn-danger

标签: css html


【解决方案1】:

正确的 CSS 规则是

.btn.btn-danger {
    background-color: orange;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-01
    • 1970-01-01
    • 2018-02-05
    • 1970-01-01
    • 2014-05-17
    • 2020-07-23
    相关资源
    最近更新 更多