如何给句子中的特定字符串设置颜色以区别于其他字符串?
我试过用粗体
"<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/