使用 Html.TextAreaFor 时如何更改字体和颜色?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2911634/
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-29 03:12:05 来源:igfitidea点击:
How to change the font & color when using Html.TextAreaFor?
提问by AwkwardCoder
I'm using following code to display some text and it won't change the font color, anyone know why?
我正在使用以下代码来显示一些文本,它不会改变字体颜色,有人知道为什么吗?
<%= Html.TextAreaFor(m => m.Component.ApplicationDescription, new { cols = "40%", Style = new Style { ForeColor = Color.Red } })%>
回答by Darin Dimitrov
<%= Html.TextAreaFor(m => m.Component.ApplicationDescription,
new { cols = "40%", style = "color:red;" })%>
or apply a css style:
或应用 css 样式:
<%= Html.TextAreaFor(m => m.Component.ApplicationDescription,
new { cols = "40%", @class = "foo" })%>
which could look like this:
看起来像这样:
.foo {
color: red;
}