HTML
  Home arrow HTML arrow Page 3 - 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 - CSS Properties to Use


    (Page 3 of 4 )

    While you are placing elements in your HTML file in the normal flow, place the first image you want for the layers, where you want the layers to be. Give this image the position property with an absolute value in your CSS. Do not give the left and top properties to the image.

    Place the next image for the layers immediately after the above one in the normal flow in your HTML file. Give this second image the same CSS properties (absolute position, no left and no top properties) as you did for the first one. Continue in this way for the rest of the images you want for the layers. With these CSS conditions you will have layers of images. The first one that you placed in the normal flow will appear in front. The rest will be behind this first one in the order they were placed in the normal flow.

    You can make any of these images appear in front; you can make any of them  appear behind the first; you can decide the order in which they will be displayed. You do this using the CSS z-index property. Any element can have the z-index property.

    The z-index value is an integer. With layers, the image (element) with the highest z-index value appears first (in front), the one with the next higher value appears behind the first; the one with the third higher value appears next, and so on. In other words, if every image in the layers is given a z-index property (integer), then the order in which the images were placed in the normal flow is nullified (ignored). I usually give the BODY element a z-index value of zero and the elements (images) in the layers receive z-index values above zero.

    When an element (image) has the absolute position property, it either appears in front of or behind the elements in the normal flow, depending on the z-index values. It does not occupy any area space in the normal flow. However, you can make it (or rather its left-top corner) appear in a particular point on the web page, by placing it in the normal flow and "deliberately" omitting its CSS Left and Top properties (as I indicated above).

    Special Functions to Use

    Images in layers are said to be in a stack. So each image has a position in the stack. The one with the highest z-index value appears in front and you can say it takes the first position in the stack. You change the images continuously on the web page by changing the positions of the images in the stack. For any image that you want to appear in front, just give it the highest z-index value; give the image that you want to leave the front a lower index value. The following code segment does this for both examples.


    function beChanging()

    {


    // displace each of the images in the stack by one position (difference of 1 unit)

     

    setTimeout("beChanging()",1000);

    }


    The setTimeout is a DOM function that JavaScript uses. In our examples, the first parameter of the function is a call to a function. The function we have called is beChanging() which contains this setTimeout function. The second parameter in the setTimeout function gives the amount of time the setTimeout function has to wait before it calls the function quoted in its first parameter.

    The setTimeout function on its own will call the function quoted in its first parameter once. However, since the setTimeout function in this case calls a function, which contains the setTimeout function, we end up with an infinite loop. In this infinite loop, our function beChanging() keeps calling itself.

    Note: While this infinite loop is being executed on the web page, other events from the web page can be called.

    More HTML Articles
    More By Chrysanthus Forcha


       · 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 4 Hosted by Hostway
    Stay green...Green IT