【问题标题】:Can't change inactive color of bootstrap button text无法更改引导按钮文本的非活动颜色
【发布时间】:2017-05-18 06:05:25
【问题描述】:

我是 bootstrap、css 和 html 的新手,但到目前为止它看起来很友好。我有一些按钮问题,我不知道该怎么想。主要是,我希望按钮中的文本是黑色的,然后只在悬停时加下划线。我尝试先做一些内联 css,但没有用,所以我想“让我们尝试在 bootstrap.css 源代码中找到它并查看更改颜色”,这正是我所做的,它适用于悬停文本,但不是其他,这是我所做的更改:

.text-info{color:#31708f}a.text-info:focus,a.text-info:hover{color:#245269} 

改为:

.text-info{color:#000}a.text-info:focus,a.text-info:hover{color:#000}

并且在 bootstrap.css 中没有出现任何其他 text-info。如果它有帮助,这里是按钮在第一列中的容器行:

<div class="row">
    <div class="col-sm-6 col-md-6 col-lg-6" >
        <div class="well"><a href="" class="btn-warning btn-block text-center text-info">Button</a></div>
    </div>
    <div class="col-sm-6 col-md-6 col-lg-6">
                div class="well">This is the first row and second column</div>
</div>

你可以从我行中的文字看出我是新来的。我认为唯一可能相关的另一件事是我在排队时覆盖了井的颜色。任何建议表示赞赏。我标记了django,因为它是唯一与统计无关的(除了推特)引导相关标签。巧合的是,我只是想美化我由 'django' 驱动的丑陋的 shell 网站!提前感谢您的任何建议。

【问题讨论】:

  • 在页面中添加 CSS 而不是编辑 bootstrap.css 似乎可行。 See this JSFiddle here 它似乎有效。您能否详细说明从您的角度来看什么不是真正有效的?

标签: css html twitter-bootstrap django-bootstrap3


【解决方案1】:

这些是控制您尝试使用的“btn 警告”行为的类。

.btn-warning {
  color: #ffffff; /*Make the color Change Here*/
  background-color: #f0ad4e;
  border-color: #eea236;
}

.btn-warning:hover,
.btn-warning:focus,
.btn-warning:active,
.btn-warning.active,
.open .dropdown-toggle.btn-warning {
  color: #ffffff;
  background-color: #ed9c28;
  border-color: #d58512;
text-decoration:underline;
}

.btn-warning:active,
.btn-warning.active,
.open .dropdown-toggle.btn-warning {
  background-image: none;
}

.btn-warning.disabled,
.btn-warning[disabled],
fieldset[disabled] .btn-warning,
.btn-warning.disabled:hover,
.btn-warning[disabled]:hover,
fieldset[disabled] .btn-warning:hover,
.btn-warning.disabled:focus,
.btn-warning[disabled]:focus,
fieldset[disabled] .btn-warning:focus,
.btn-warning.disabled:active,
.btn-warning[disabled]:active,
fieldset[disabled] .btn-warning:active,
.btn-warning.disabled.active,
.btn-warning[disabled].active,
fieldset[disabled] .btn-warning.active {
  background-color: #f0ad4e;
  border-color: #eea236;
}

对 html 进行这些更改

<div class="row">
    <div class="col-sm-6 col-md-6 col-lg-6" >
        <div class="well"><a href="" class="btn btn-warning">Button</a></div>
    </div>
    <div class="col-sm-6 col-md-6 col-lg-6">
                div class="well">This is the first row and second column</div>
</div>

【讨论】:

  • @ThisGuyCantEven 检查一下...你可以在 bootstrap.css 文件中找到这些类。
  • 谢谢库马尔,这也回答了我的问题,抱歉我不能同时检查。我已经看过btn-warning 类,但是,他们并没有非常直观地命名。尽管现在我知道这是我之前传递过的文本,这很有意义。
【解决方案2】:

您可以添加自定义 css 文件并在加载 bootstrap.css 后加载它。这将覆盖设置,我从不弄乱 bootstrap.css,因为我从其他地方而不是本地加载它。

编辑:您也可以内联更改它(html 明智),但这不是我们喜欢分离关注点的好习惯。

另外,没有看到引导程序更改的问题可能是缓存,我在this link找到了一个不错的技巧

祝你好运

【讨论】:

  • 哇,在.html 文档中进行内联更改效果很好。我恢复了对引导程序所做的更改。我没有制作新样式表的原因是因为这实际上只是这个特定页面的方案,所以我只是在&lt;head&gt;&lt;/head&gt; 中制作了一个内联样式表。希望我能投票,因为仍然是很好的建议。
  • 更改内联与在稍后加载的第二个 css 文件中更改它相同。您还覆盖了引导程序样式。如果这对您有所帮助,您可以接受它作为答案,以便其他人也可以使用它
  • 如果他们有更好的带宽/服务器或不,从 url 加载引导程序更好吗?
  • 实际上大多数人这样做是因为人们的缓存中有引导程序。更好.. 取决于,它为您节省了少量带宽,我总是说如果这些服务存在,您为什么不使用它们? :)。在我看来,这种工作方式的优点是您只需更改 css 参考中的版本号,而不是将新版本上传到您的网站。
猜你喜欢
  • 2021-06-28
  • 2018-02-05
  • 1970-01-01
  • 2018-03-23
  • 2015-09-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多