为什么CSS类被忽略? [英] Why is CSS class being ignored?

查看:88
本文介绍了为什么CSS类被忽略?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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>

如您所见,我给它添加了一个白色"类.定义CSS的目的是使按钮中文本"Delete it"的颜色为白色. CSS如下:

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;
}

问题是CSS中除"color"以外的所有选项都可以正常工作.例如,在上述情况下,背景颜色"效果很好,但颜色"效果不好.文本的颜色从不改变(保留默认值-黑色).

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?

推荐答案

看起来好像您正在使用Bootstrap.加载Bootstrap之后是否加载了自定义CSS文件?要快速修复,您可以尝试:

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.

要找出哪个CSS实际为文本提供了颜色,请右键单击它,检查元素(或浏览器所需的内容),然后按照上面的建议检查计算出的CSS.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆