[英]How do I change the color of javascript text?
所以我有一些 JavaScript 可以創建單獨的文本。
當我調用它時,要輸入文本,我會執行以下操作:
<center><p id="w00t"><font color="white">text here</font></p></center>
<script type="text/javascript">
new TypingText(document.getElementById("w00t"), 50, function(i){ var ar = new Array("\\", "|", "/", "-"); return " " + ar[i.length % ar.length]; });
//Type out examples:
TypingText.runAll();
</script>
但是,我的網頁背景是黑色的,它打印了行尾數組:
new Array("\\", "|", "/", "-"); return " " + ar[i.length % ar.length]; });
作為黑色。
我怎樣才能讓它變白?
首先刪除字體標簽。 它不再使用,在這種情況下您當然不需要它。
要為文本着色,請使用以下代碼:
document.getElementById("w00t").style.color = "#FFFFFF";
首先我會小心你使用什么標簽。 <center><font>
都已被棄用,很快將不再受支持。
使用類或 styles 更改文本顏色。
#w00t
{
color:white;
}
由於我假設您是帶有<font>
標記等的老派,因此將其添加到您的<head>
中,使其看起來像這樣:
<head>
<style type="text/css">
body {
background-color:#000; // background color black
color:#FFF; // font color white
}
</style>
</head>
使用 CSS 樣式。 將元素的 style.color 設置為您想要的顏色。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.