JavaScript
  Home arrow JavaScript arrow Using the DOM to Build Dynamic Shadows wit...
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? 
JAVASCRIPT

Using the DOM to Build Dynamic Shadows with JavaScript and CSS
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating:  stars stars stars stars stars / 0
    2009-07-06

    Table of Contents:
  • Using the DOM to Build Dynamic Shadows with JavaScript and CSS
  • Reviewing some previous shadowing techniques
  • Creating dynamic shadows with the DOM
  • The shading application’s full source code

  • 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


    Using the DOM to Build Dynamic Shadows with JavaScript and CSS


    (Page 1 of 4 )

    A proper combination of JavaScript code and CSS styles can be the perfect recipe for incorporating eye-catching effects into a certain number of elements included in a given web document. This three-part series of articles walks you through creating dynamic shadows using unobtrusive client-side scripting, so if you’re interested in learning how to implement this visual effect within your own web pages, then you’ve come to the right place.

    Introduction

    Welcome to the second part of the series. As I said above, this series shows you different approaches for building pretty realistic shadows using JavaScript and some basic CSS styles. It complements the theoretical side of this topic with illustrative hands-on examples.

    If you already went through the first installment of this series, then it’s quite probable that creating basic shading effects utilizing some simple CSS styles is now familiar to you. In that specific tutorial I provided you with a few examples that showed you how to achieve this neat effect with minor hassles.

    First I showed you how to incorporate a basic shadow into a targeted DIV within a sample web page by using just a background image, which was properly attached to the DIV in question via CSS.

    While this approach probably is the simplest to implement, it comes with plenty of limitations. It can only be applied in certain cases where the web page element that will be linked to the shadow has fixed dimensions. This is actually a very unusual situation.

    However, I also showed you how to build basic shading effects by tweaking the “border-style” property of a DIV, in this case by specifying an “outset” value for its border CSS property. Nonetheless, the results achieved with this technique are rather unreliable, since each browser displays the border property of a given element in different ways, which severely restricts the use of this method.

    Not all is lost, though, when it comes to including dynamic shadows in a web document. Actually, there are some other approaches that use a combination of clean JavaScript and CSS styles that can be implemented with relative ease. Therefore, in this second article of the series, I’ll be taking a close look at them, and show you how to use them to incorporate realistic shadows into different elements of a web page.

    As you’ll see for yourself in the next few lines, these methods will use a proper combination of the DOM and CSS to build dynamic shadows, so go ahead and start reading now!

    More JavaScript Articles
    More By Alejandro Gervasio


       · This chapter of the series shows how to use a proper combination of the DOM and CSS...
     

    JAVASCRIPT ARTICLES

    - Validating Digits and Dates with jQuery`s Va...
    - Validating Ranges, Emails, and URLs with jQu...
    - More Uses for the jQuery Tooltip Plug-in`s b...
    - Building Image-Based Tooltips with the jQuer...
    - Using the jQuery Tooltip Plug-in`s bodyHandl...
    - Using Rangelength, Min and Max with the Vali...
    - Using Minlength and Maxlength with the Valid...
    - Modifying Tooltip Coordinates with the jQuer...
    - Applying a Fade Out Effect with the jQuery T...
    - Tracking Mouse Movements with the jQuery Too...
    - Checking Online Forms with the Validator jQu...
    - Nested JavaScript Functions as Objects
    - The jQuery Tooltip Plug-in
    - Active Client Pages at the Server
    - ACP Tab Web Page







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