HTML
  Home arrow HTML arrow Page 4 - Changing and Moving Pictures with CSS
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
HTML

Changing and Moving Pictures with CSS
By: Chrysanthus Forcha
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 11
    2008-06-09

    Table of Contents:
  • Changing and Moving Pictures with CSS
  • Moving Pictures Demonstration
  • CSS Properties to Use
  • Algorithm

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Changing and Moving Pictures with CSS - Algorithm


    (Page 4 of 4 )

    Here I explain the algorithm for both examples.

    • Since an image with absolute position would cover elements in normal flow, do not put any element in normal flow under the image stack. In these examples, the image stack is put in a table cell that has no content. The dimensions of the table cell are the same as the dimensions of each of the image. The images all have the same dimensions.

    • At any instant we see only the image in front. So give the image that is to appear in front a z-index value of 2, and give the rest that come behind a z-index value of 1. With a z-index value of 1, they will still be placed in order, but this time their order will depend in the order they were placed in the normal flow.

    • Use a timing function inside an infinite loop to changing the z-indices (2 and 1) of the images in the stack.


    Changing Images

    In this section I talk about the first example. The images all concern themselves with the topic of education. So while the user is reading other things on the web page, the changing images are calling his attention to education or a particular aspect of education. The time interval between each new picture coming up is 1000ms (1s).

    The variables A, B, C, D and Temp are used to change the z-index values of the images each time the function "beChanging()" is called.

    You can now read through the code of the first example and fully understand it.

    Moving Images

    In this section I talk about the second example. Here we are dealing with moving images (video). The images are indicated below in the order (from left to right, top to bottom) in which they are displayed.




    Fig1. Similar images in order


    The aim here is to display a ball that moves through an arc repeatedly. So the order of the images must always be respected. From one image to the next, there is only a small difference in the picture. The images above have been listed in the order in which they appear on the screen. After the last image appears, the cycle repeats. The code is similar to the one above, but here you must respect the order in the stack to have a continuous movement of the ball. Also, here the time interval is smaller: 100ms.

    Application of moving CSS/JavaScript images

    When you do something like what we have done for the second example, you actually form a video clip. If you want the movement to be very natural you need to display at least 25 similarly varying images in one second. This means that the time interval has to be at most 40ms. The problem here is that 25 images will take a long time to download. So you can limit this technique to highlights of scenes where you will use fewer images.

    Conclusion

    You can develop your own small clips using HTML, CSS and JavaScript. You put the images in layers to form a stack. Use a JavaScript function to rotate the image positions in the stack.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · If you thought that you cannot make images move, you thought wrong. This article...
     

    HTML ARTICLES

    - Comparing Browser Response to Active Client ...
    - Testing Browser Response to Active Client Pa...
    - Active Client Pages: Completing the Code for...
    - ACP and Browsers: Setting up an Example
    - How Browsers Respond to Active Client Pages
    - Completing a Tree with Active Client Pages
    - HTML Form Verification and ACP
    - Building an ACP Tree
    - Completing an ACP 3D HTML Table Image Gallery
    - Building an ACP 3D HTML Table Image Gallery
    - A Multiple Page Image Gallery with Active Cl...
    - Building an Image Gallery with Active Client...
    - Concluding a Menu for All Browsers
    - A Vertical Menu for All Browsers
    - Downloading Long HTML Pages with ACP







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    Stay green...Green IT