Html 如何更改css类的文本颜色?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40010625/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change text color of a css class?
提问by el323
I am using Bootstrap.css, and there's a class named "form-control". I am using this class to style my aspx controls. The problem is that its textbox font color is grey and I want it to be black. I have no clue about CSS. Is there a way I can change that from grey to black? Thanks.
我正在使用 Bootstrap.css,并且有一个名为“form-control”的类。我正在使用这个类来设置我的 aspx 控件的样式。问题是它的文本框字体颜色是灰色的,我希望它是黑色的。我对 CSS 一无所知。有没有办法可以将其从灰色更改为黑色?谢谢。
回答by Ash
You can reset the text color of class - 'form-control' by adding
您可以通过添加重置类的文本颜色 - 'form-control'
.form-control {
color:#000000;
}
Add this property in a separate css file and include it just below bootstrap.min.css in head tag.
将此属性添加到单独的 css 文件中,并将其包含在 bootstrap.min.css 下方的 head 标记中。
回答by Edmar Miyake
If you want all the textboxes font color to be black, add this:
如果您希望所有文本框字体颜色为黑色,请添加以下内容:
input[type="text"] { color: black }
in your CSS file.
在你的 CSS 文件中。
Otherwise, create a class:
否则,创建一个类:
.black-input {
color: black
}
<input type="text" class="black-input">
<input type="text" class="black-input">
回答by LStarky
Go to http://getbootstrap.com/customize/and select the colors you want, then Compile and Download at the bottom.
转到http://getbootstrap.com/customize/并选择您想要的颜色,然后在底部编译和下载。
回答by HuntsMan
use this:
用这个:
.input-black {
// this is the one can change the color of a text even if its a placeholder
color: black;
}
<input type="text" class="input-black">
回答by Patrick H.
You would need to add some code like this to your CSS file.
您需要将一些这样的代码添加到您的 CSS 文件中。
.form-control {
color: #000;
}
Keep in mind that you may have some specificity declaration issues. For example, if the color is set in bootstrap.css as a child of another element, you may not be able to override the color change unless you declare it with the parent as well. For example:
请记住,您可能会遇到一些特殊性声明问题。例如,如果在 bootstrap.css 中将颜色设置为另一个元素的子元素,则您可能无法覆盖颜色更改,除非您也将其声明为父元素。例如:
.parent .form-control {
color: #000;
}
You shouldn't be scared to learn some CSS though. It's very easy to grasp (you'll literally get the basics in less than an hour).
不过,您不应该害怕学习一些 CSS。它非常容易掌握(您将在不到一个小时的时间内掌握基本知识)。