| :blue}
</style>
</head>
<body>
<p><a href="www.microsoft.com">
这是一个最简单的利用CSS技术控制文本颜色的例子.</a></p>
</body>
</html>
在这个示例中,链接文字起初用红色显示,当鼠标划过文字时变为蓝色,点击访问时改为紫红色,访问之后又变为栗色。由于Netscape还不支持link、visited、hover等CSS属性,因此,您要是用Communicator 的话,就看不到这些效果了。
第二种方法是利用 JavaScript编写一个小脚本程序来运行,从而起到变色的目的。它的示例代码如下。
<html>
<head>
<title>Change text color</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
.css1 { font-family: "Courier New", Courier, mono; font-size: 14pt; font-style: normal; line-height: normal; font-weight: bold; color: blue}
-->
</style>
<script language="JavaScript">
function MM_changeProp(objStrNS,objStrIE,theProp,theValue) {
var theObj = eval((navigator.appName == 'Netscape')?objStrNS:objStrIE);
if ((theObj != null) && (theProp.indexOf("style.") != 0 &&
theObj.style != null))
eval(((navigator.appName == 'Netscape')?objStrNS:objStrIE)+'.'+theProp + '="'+theValue+'"');
}
</script>
</head>
<body bgcolor="#FFFFFF">
<span class="css1" ID="x"
on 上一页 [1] [2] [3] [4] [5] [6] [7] 下一页 |