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

首頁 > 學院 > 開發設計 > 正文

用ASP+CSS實現隨機背景

2019-11-18 17:11:32
字體:
來源:轉載
供稿:網友

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

ASP--來自ASP101

以下是引用片段:
Const IMGS_DIR = "/images" 
 '設定圖片文件夾的地址,隨機顯示該文件夾內任一張圖片
Dim objfso, objFolderObject, objFileCollection, objFile
Dim intFileNumberToUse, intFileLooper
Dim objImageFileToUse
Dim strImageSrcText
Set objFSO = Server.CreateObject("ScrSet 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{
    width: 400px;
    height: 300px;
    background: url(<%= strImageSrcText %>) no-repeat;
    margin: 2em auto;
}

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


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 稻城县| 阿拉尔市| 宜春市| 罗源县| 兴国县| 襄樊市| 桓仁| 乐业县| 宁河县| 平安县| 鹿邑县| 蓬安县| 淄博市| 株洲市| 襄樊市| 洞头县| 苏尼特左旗| 台山市| 巴南区| 西吉县| 南宁市| 胶南市| 文安县| 陆河县| 常熟市| 文山县| 顺昌县| 乐至县| 兰州市| 台中市| 盖州市| 伊春市| 平罗县| 革吉县| 青龙| 甘肃省| 牙克石市| 黎平县| 新巴尔虎左旗| 绥德县| 新巴尔虎右旗|