c# - 给一句话设置颜色?

标签 c# html css asp.net

如何给句子中的特定字符串设置颜色以区别于其他字符串?

我试过用粗体

"<b>" + myValue + "<b>"

我认为如果我以彩色格式显示它会很好。这是如何实现的

最佳答案

您可以使用内联样式标签设置特定句子的颜色:

对于标题:

<h1 style="color:blue">This is a Blue Heading</h1>

或者对于一个段落:

<p style="color:red">This is a red Paragraph</p>

或者你想要的任何地方:

<span style="color:blue">Some blue text</span>

甚至在另一个句子中:

<p>This is a boring paragraph <span style="color:green">with some amazing green text!</span> boring again...</p>

使用 javascript 变量:

<script>
var string = "This is a string";
document.getElementById("myText").style.color = "red";
document.getElementById("myText").innerHTML=string;
</script>

<span id="myText"></span>

关于c# - 给一句话设置颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31633473/

相关文章:

php - 如何在不引用外部 CSS 文件的情况下在 WordPress PHP 文件中创建内联 CSS?

css - 定位当前窗口右下角的元素

html - 将鼠标悬停在父级上以触发变换属性

c# - MVC3通过ModelState添加和显示消息

c# - 将 View 模型绑定(bind)到 View

Javascript 在 mailto 正文中添加换行符

html - 标题 li 元素不会并排对齐

html - 两个表的 Z-index 不能正常工作

c# - 如何从基类的 ObserveableCollection 中显示子类的属性?

c# - 如何使用 MemoryCache 代替 Timer 来触发方法?