酷络网游
 | 网站首页 | 网游新闻 | 网络游戏 | 电脑游戏 | 电视游戏 | 电子竟技 | 手机游戏 | 美眉专区 | 
>>> 您现在的位置: 酷络网游 >> 网页制作 >> 文章正文
| 最新推荐
| 最新热门
| 相关文章
没有相关文章
 用ASP+CSS来实现网页随机背景的显示


    随机背景--当你每次进入该页面时,从已指定的图片文件夹中,随机选取一个图片作为背景显示。这里介绍的方法是用ASP+CSS来实现的。
  ASP源代码:

以下是引用片段:
  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{
  width: 400px;
  height: 300px;
  background: url() no-repeat;
  margin: 2em auto;
  }


  上面代码要加在head区,不能放在外部CSS文件里。

 

作者:-  更新时间:2006-10-27
本文由酷络网友发表,版权归原作者[ - ]所有,并不代表酷络本站观点,转载请注明出处和作者。
抵制不良游戏,拒绝盗版游戏。注意自我保护,谨防受骗上当。适度游戏益脑,沉迷游戏伤身。合理安排时间,享受健康生活。
  • 上一篇文章:

  • 下一篇文章:
  • 网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
     | Copyright @ 2005-2010 www.kuluo.com All Rights Reserved. 桂ICP证05014479号 酷络站长:踏浪 联系站长:67033171  站长在线
     | 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告合作 | | |