DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

CSS Drop Shadows

12.12.2006
| 18556 views |
  • submit to reddit
        This handy technique allows us to build flexible CSS drop shadows that we can apply to any arbitraryblock elements. The beauty of this method is that most exisitng techniques use images to create the shadow effect. This script is lightweight and uses pure CSS! ENJOY!
<a href="http://www.webscriptexpert.com">www.webscriptexpert.com</a>

<HTML PAGE HERE>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>CSS Drop Shadow DEMO</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link media="screen" type="text/css" rel="stylesheet" href="dropshadow.css" />

<style>
body {
margin: 0px;
padding: 20px;
font-family: verdana;
font-size: 12px;
min-width: 770px;
}
</style>

</head>

<body>

<div id="shadow-container">
<div class="shadow1">

<div class="shadow2">
<div class="shadow3">
<div class="container">
<p>This is a sample of how we implement the CSS style to create flexible CSS drop shadows that can be applied to block elements.</p>
<p>The beauty of this script is that is doesnt use any images to create the final effect, just pure CSS!</p>
</div>
</div>
</div>
</div>
</div>

<br />
<br />

<table cellspacing=0 cellpadding=0 border=0 width="100%"><tr valign="top">
<td width="22%" height="218">
<div id="shadow-container">
<div class="shadow1">
<div class="shadow2">
<div class="shadow3">
<div class="container">
The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. </div>

</div>
</div>
</div>
</div>
</td>
<td width="21%"></td>
<td width="57%">
<div id="shadow-container">
<div class="shadow1">
<div class="shadow2">

<div class="shadow3">
<div class="container">The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. </div>
</div>
</div>
</div>
</div>
</td>
</tr></table>

</body>
</html>



<.CSS FILE HERE>

/* CSS container shadow */
#shadow-container {
position: relative;
left: 3px;
top: 3px;
margin-right: 3px;
margin-bottom: 3px;
}

#shadow-container .shadow2,
#shadow-container .shadow3,
#shadow-container .container {
position: relative;
left: -1px;
top: -1px;
}

#shadow-container .shadow1 {
background: #F1F0F1;
}

#shadow-container .shadow2 {
background: #DBDADB;
}

#shadow-container .shadow3 {
background: #B8B6B8;
}

#shadow-container .container {
background: #ffffff;
border: 1px solid #848284;
padding: 10px;
}
/* CSS container shadow */