CSS 如何更改文本区域中的字体颜色

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/44203608/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 12:34:05  来源:igfitidea点击:

How to change the font color in a textarea

css

提问by John

Right now I have a text area that gets it's text from a string. I have the background color set to black for the text-area, however the default text color is black, so until you highlight it you can't see it. I can't seem to find a way to change the font color to white. Is there an easy way in CSS to do this?

现在我有一个文本区域,可以从字符串中获取文本。我将文本区域的背景颜色设置为黑色,但是默认文本颜色是黑色,因此在突出显示它之前您是看不到它的。我似乎找不到将字体颜色更改为白色的方法。CSS 中有一种简单的方法可以做到这一点吗?

html

html

<div class="mainWindow">
  <div class="valueOutput" [hidden]="hideThis">
    <textarea resize=none readonly="textareaEdit" rows="8" cols="50" style="background-color: black;" [(ngModel)]="outputTexT" ></textarea>
  </div>
  <div class="labelOutput" [hidden]="hideThis">
    <textarea readonly="textareaEdit" rows="8" cols="46" style="background-color: black;" [(ngModel)]="labelText"></textarea>
  </div>
  <textarea rows="20" cols="91" [style.font-size.px]="20" [style.padding-top.px]="130" readonly="textareaEdit" style="background-color: #b6b7b4;" [(ngModel)]="mainStepText"></textarea>
</div>

string used for textarea

用于 textarea 的字符串

private labelText: String = "test1 \ntest2 \ntest3";

current CSS

当前的 CSS

.mainWindow{
width: 1000px;
    height: 310px;
    vertical-align: middle;
    resize: none; 
    overflow: auto; 
    -ms-overflow-style: none; 
    background-color: #B5B6B6;
}
.valueOutput{
    position: absolute;
    resize: none !important;
    padding-left: 600px;
}
.labelOutput{
    position: absolute;
    resize: none !important;
    padding-left: 250px;
}

回答by Suraj Lulla

  1. For inline CSS, you can change the styleto following:
  1. 对于内联 CSS,您可以将样式更改为以下内容:

style="background-color: black;color:#fff;"

  1. Or you can add the following in your CSS file:
  1. 或者您可以在 CSS 文件中添加以下内容:

textarea {
    color: #fff;
}