文字顏色的設(shè)置
文章導(dǎo)讀:
<html>
<head>
<title>文字顏色</title>
<style type="text/css">
<!--
body{
font-family:Arial, Helvetica, sans-serif;
font-size:13px;
}
form{padding:0px;margin:0px;}
input{
border:1px solid #000000;
width:40px;
}
input.btn{width:60px; height:18px;}
span{font-family:黑體;font-size:60px; font-weight:bold;}
-->
</style>
<script language="javascript">
function ChangeColor(){
var red = document.colorform.red.value; //獲得各個(gè)輸入框的值
var green = document.colorform.green.value;
var blue = document.colorform.blue.value;
var obj = document.getElementById("text");
obj.style.color="#"+red+green+blue; //修改文字顏色
}
</script>
</head>
<body>
<form name="colorform">
R:<input name="red" maxlength="2">
G:<input name="green" maxlength="2">
B:<input name="blue" maxlength="2">
<input type="button" onClick="ChangeColor()" value="換顏色" class="btn">
</form>
<br>
<span id="text">CSS層樣式</span>
</body>
</html>