Results 1 to 2 of 2

Thread: CSS Background

  1. #1
    Join Date
    Mar 2009
    Posts
    8
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default CSS Background

    Thank you for your time reading this post.

    I was wondering if there is a way (with CSS or some other language) to change my background color like this:

    The first five seconds - gray.
    The next 15 seconds - black.
    Then make it stay gray.

    If you have any ideas even beyond css please let me know.

    Thank you.

  2. #2
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    693
    Thanks
    1
    Thanked 113 Times in 111 Posts

    Default

    Hi there WattCode,

    this will require a little javascript...
    Code:
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="language" content="english"> 
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    
    <title></title>
    
    <style type="text/css">
    body {
        background-color:#999;
     }
    .black {
        background-color:#000;
     }
    </style>
    
    <script type="text/javascript">
    
       var c=0;
    
    function changeBg(){
    if((c>5)&&(c<21)) {
       document.body.className='black';
     }
       c++;
    if(c>21){
       document.body.className='';
       clearTimeout(sto);
       return;
    }
       sto=setTimeout(function(){changeBg()},1000);
     }
    
    if(window.addEventListener){
       window.addEventListener('load',changeBg,false);
     }
    else { 
    if(window.attachEvent){
       window.attachEvent('onload',changeBg);
      }
     }
    </script>
    
    </head>
    <body>
    
    <div></div>
    
    </body>
    </html>
    
    coothead

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •