Old 11-04-2009, 09:33 AM   #1
RebeccaLessay
Registered User
animated background

Few questions about a background,

1) I have a tileable image (PNG) I want to move in the background (clouds, they move slowly from the right to the left) is this possible to do in HTML?

2) If question 1 is possible, can it still preserve the transparency?

Thanks in advance
RebeccaLessay is offline   Reply With Quote

Sponsored Links (Guests Only) - Register | Need Help?
 

Old 11-04-2009, 10:20 AM   #2
project107
Registered User
 
project107's Avatar
It's possible with Javascript, although I have no idea how hard it would hit the client machine.

__________________
project107 is offline   Reply With Quote
Old 11-04-2009, 11:44 AM   #3
Swooter
Swooter - AS/JS/HTML/CSS
 
Swooter's Avatar
Try this:
HTML Code:
<html>

  <head>
    <style type="text/css">
      div#cloud {
        position: absolute;
        left: 0px;
        top: 0px;
        width: 453px;
        height: 283px;
        background-image: url("http://www.seul.org/~grumbel/tmp/cloud.png");
        z-index: 0;
      }
    </style>
  </head>
  <body>
    <div id="cloud"></div>
    <script type="text/javascript">
      var $cloud = document.getElementById("cloud");
      var $amount = 10;
      var $speed = 100;

      function moveLeft() {
        if ( $cloud.offsetLeft > 0 ) {
           $cloud.style.left = ($cloud.offsetLeft - $amount) + "px";
           setTimeout(moveLeft, $speed);
        } else {
           setTimeout(moveRight, $speed);
        }
      }

      function moveRight() {
        if ( $cloud.offsetLeft < (document.body.offsetWidth-$cloud.offsetWidth) ) {
           $cloud.style.left = ($cloud.offsetLeft + $amount) + "px";
           setTimeout(moveRight, $speed);
        } else {
           setTimeout(moveLeft, $speed);
        }
      }
      moveRight();
    </script>
  </body>
</html>

__________________

AS / JS / HTML / CSS / PHP
Swooter is offline   Reply With Quote
Old 11-06-2009, 07:16 AM   #4
RebeccaLessay
Registered User
Quote:
Originally Posted by Swooter View Post
Try this:
HTML Code:
<html>
 
  <head>
    <style type="text/css">
      div#cloud {
        position: absolute;
        left: 0px;
        top: 0px;
        width: 453px;
        height: 283px;
        background-image: url("http://www.seul.org/~grumbel/tmp/cloud.png");
        z-index: 0;
      }
    </style>
  </head>
  <body>
    <div id="cloud"></div>
    <script type="text/javascript">
      var $cloud = document.getElementById("cloud");
      var $amount = 10;
      var $speed = 100;
 
      function moveLeft() {
        if ( $cloud.offsetLeft > 0 ) {
           $cloud.style.left = ($cloud.offsetLeft - $amount) + "px";
           setTimeout(moveLeft, $speed);
        } else {
           setTimeout(moveRight, $speed);
        }
      }
 
      function moveRight() {
        if ( $cloud.offsetLeft < (document.body.offsetWidth-$cloud.offsetWidth) ) {
           $cloud.style.left = ($cloud.offsetLeft + $amount) + "px";
           setTimeout(moveRight, $speed);
        } else {
           setTimeout(moveLeft, $speed);
        }
      }
      moveRight();
    </script>
  </body>
</html>
thanks!
I knew this was possible in actionscript but wasnt sure if html had the this moving option too.
RebeccaLessay is offline   Reply With Quote
Old 11-06-2009, 09:31 AM   #5
simplistik
PseudoMex
 
simplistik's Avatar
Location Tallahassee, FL

Posts 9,959
Quote:
Originally Posted by RebeccaLessay View Post
thanks!
I knew this was possible in actionscript but wasnt sure if html had the this moving option too.
it doesn't, but javascript does

__________________
Let us live so that when we come to die even the undertaker will be sorry. - Mark Twain
Don't PM me your CSS, xHTML, JS or PHP questions. I will not reply to ANY IE6 questions.
simplistik is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:51 PM.

SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
Creative web apps. Make your own free flash banners and photo slideshows.
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.

Flash Transition Effects

Flash Effect Tutorials

Digicrafts Components
Flash effects. Art without coding. Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com
Streamsolutions Content Delivery Networks Flipping Book - page flip flash component.
Flash-Gallery.com - Get your flash photo gallery (flash component or swf gallery Learn how to advertise on kirupa.com
 

cdn
content delivery network (cdn)

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Copyright 2010 - kirupa.com Copyright 2010 - kirupa.com