Home arrow JavaScript arrow Using the DOM to Build Dynamic Shadows with JavaScript and CSS
JAVASCRIPT

Using the DOM to Build Dynamic Shadows with JavaScript and CSS


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.

Author Info:
By: Alejandro Gervasio
Rating:  stars stars stars stars stars / 0
July 06, 2009
TABLE OF CONTENTS:
  1. · Using the DOM to Build Dynamic Shadows with JavaScript and CSS
  2. · Reviewing some previous shadowing techniques
  3. · Creating dynamic shadows with the DOM
  4. · The shading application’s full source code

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Using the DOM to Build Dynamic Shadows with JavaScript and CSS
(Page 1 of 4 )

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!


blog comments powered by Disqus
JAVASCRIPT ARTICLES

- More Top jQuery Tutorials for Beginners
- More Top jQuery Plugins for Menus
- Top jQuery Tutorials for Beginners
- New UI Framework and SDK for JavaScript Rele...
- JavaScript OpenPGP Tool, Node.js 0.6.3 Avail...
- Yahoo Releases Cocktails Language and Develo...
- Customizing jQuery Slideshows: Dynamic Contr...
- Customizing jQuery Slideshows: the animate()...
- Customizing jQuery Slideshows: slideUp() and...
- Customizing jQuery Slideshows: hide() and sh...
- Web Workers: Performing Calculations in Para...
- More Top JavaScript Frameworks and Libraries
- More Dynamic jQuery Styling Techniques
- The Top JavaScript Libraries
- The Top JavaScript Frameworks

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 1 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials