CSS“颜色”不工作 [英] CSS "color" not working
问题描述
我有一个 link_to
,如下所示:
td><%= link_to'< span class =glyphicon glyphicon-trash>< / span> Delete it'.html_safe,post,method::delete,data:{confirm:'Are you sure? },class:'btn btn-danger btn-lg white'%>< / td>
如你所见,我已经添加了一个类white。它的目的是定义一个CSS,使按钮中的文本删除它的颜色为白色。 CSS如下:
.white {
color:white;
background-color:yellow;
}
问题是除了color之外的所有选项在CSS 。例如,在上述情况下,背景颜色工作正常,但颜色不正常。文字的颜色永远不会改变(保持默认 - 黑色)。
我看不到我会错的地方。如何解决这个问题?
看起来你可能使用Bootstrap。在加载Bootstrap后加载自定义CSS文件?要快速修复,您可以尝试:
.white {color:white!important; }
但是很难建议作为一个永久的解决方案, / p>
要查明哪个CSS实际上是文本的颜色,右键单击它,检查元素(或任何为您的浏览器),然后检查计算CSS推荐
I have a link_to
as shown below:
<td><%= link_to '<span class="glyphicon glyphicon-trash"></span>Delete it'.html_safe, post, method: :delete, data: {confirm: 'Are you sure?'}, class: 'btn btn-danger btn-lg white' %></td>
As you can see, I have added a class "white" to it. The purpose it to define a CSS to make the color of the text "Delete it" in the button white. The CSS is as follows:
.white {
color: white;
background-color: yellow;
}
The problem is that all options other than "color" work fine in the CSS. For e.g., in the above case, "background-color" is working fine, but "color" is not. The color of the text never changes (remains default - black).
I don't see where I am going wrong. How can I resolve this?
It looks as though you might be using Bootstrap. Did you load your custom CSS file after loading Bootstrap? For a quick fix, you could try:
.white { color: white !important; }
But it's hard to recommend that as a permanent solution, it's kind of a faux-pas.
To find out which CSS is actually giving the text it's colour, right click on it, inspect element (or whatever for your browser) and then check out the computed CSS as recommended above.
这篇关于CSS“颜色”不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!