国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 建站經驗 > 正文

用ASP-+CSS實現隨機背景

2019-11-02 15:48:51
字體:
來源:轉載
供稿:網友

 隨機背景--當你每次進入該頁面時,從已指定的圖片文件夾中,隨機選取一個圖片作為背景顯示。這里介紹的方法是用ASP+CSS來實現的。

ASP--來自ASP101

以下是引用片段:
Const IMGS_DIR = "/images"
'設定圖片文件夾的地址,隨機顯示該文件夾內任一張圖片
Dim objFSO, objFolderObject, objFileCollection, objFile
Dim intFileNumberToUse, intFileLooper
Dim objImageFileToUse
Dim strImageSrcText
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolderObject = objFSO.GetFolder(Server.MapPath(IMGS_DIR))
Set objFSO = Nothing
Set objFileCollection = objFolderObject.Files
Set objFolderObject = Nothing
Randomize()
intFileNumberToUse = Int(objFileCollection.Count * Rnd) + 1
intFileLooper = 1
For Each objFile in objFileCollection
If intFileLooper = intFileNumberToUse Then
Set objImageFileToUse = objFile
Exit For
End If
intFileLooper = intFileLooper + 1
Next
Set objFileCollection = Nothing
strImageSrcText = IMGS_DIR & objImageFileToUse.Name
Set objImageFileToUse = Nothing

CSS

以下是引用片段:
#pic{
6v電影網[www.aikan.tv/special/6vdianyingwang/]
width: 400px;
height: 300px;
background: url(<%= strImageSrcText %>) no-repeat;
margin: 2em auto;
}

上面代碼要加在header區,不能放在外部CSS文件里。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 原阳县| 山西省| 嘉定区| 南丰县| 台前县| 郯城县| 黄平县| 宝兴县| 望奎县| 名山县| 祁东县| 开阳县| 平昌县| 东明县| 湛江市| 大名县| 佛冈县| 红桥区| 万宁市| 屏东市| 泸溪县| 彩票| 上林县| 泾川县| 吴桥县| 枝江市| 察哈| 隆尧县| 南京市| 论坛| 南宫市| 延安市| 思南县| 黎川县| 若羌县| 东安县| 屏山县| 香港 | 柞水县| 义乌市| 德清县|