Implement random background with ASP + CSS

Source: Internet
Author: User

Random background Effects: each time you enter the page, an image is randomly selected from the specified image folder for background display. The method described here is implemented using ASP + CSS.

The following is a reference clip:

Const imgs_dir = "/images" ': sets the address of the image folder and randomly displays any image in the folder.

Dim objfso, objfolderobject, objfilecollection, objfile dim intfilenumbertouse, intfilelow.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 intfileloaders = 1 for each objfile in objfilecollection if intfileloaders = effecthen set names = objfile exit for end if intfileloaders = intfileloaders + 1 next set objfilecollection = nothing directories = imgs_dir & others. name set objimagefiletouse = nothingcss
The following is a reference clip: # PIC {width: 400px; Height: 300px; Background: URL () No-Repeat; margin: 2em auto ;}

The above code must be added to the header area and cannot be placed in an external CSS file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.