使用CSS文件
本节内容适合已经掌握CSS的用户。
同样,教会你CSS不是我们的任务,有人干这个我们擅长很多,如果有兴趣,可以访问:http://www.w3school.com.cn/css/index.asp,通常不会超过半天时间就能基本掌握。
使用CSS文件和使用js文件的方法一样,只是CSS文件通常在head块引入,js通常在body块的结束位置引入。
一个例子
1、在"d:\web"目录下,建立一个子目录css,在这个子目录中新建一个文本文件,文件名为文件名为“test.css”,文件内容为:
.rd{color:red;}
.gr{color:green;}
2、然后修改HttpRequest事件的代码,在有变化的地方,我加上了注释:
Dim
fl As
String =
"d:\web\" &
e.path
If
filesys.FileExists(fl)
Dim idx
As Integer
= fl.LastIndexOf(".")
Dim ext
As String
= fl.SubString(idx)
Select Case
ext
Case
".jpg",".gif",".png",".bmp",".wmf",".js",".css"
'这里加上了css扩展名
e.WriteFile(fl)
End
Select
Else
Dim
html
As
String
=
<![CDATA[
<!doctype html>
<html>
<head>
<meta charset='utf-8'>
<title>CSS测试</title>
<link rel='stylesheet' href='./css/test.css'/>
</head>
<body>
<p class='rd'>This Is some text. This Is some text.</p>
<p class='gr'>This Is some text. This Is some text.</p>
</body>
</html>
]]>.Value
e.WriteString(html)
End
If
在浏览器的显示结果为:
