Solved

html div shadow effect

Posted on 2010-08-14
7
825 Views
Last Modified: 2012-05-10
I am creating a div for the entire content of my web page to be centred.

I would like to create a shadow effect on the div border. How can I achieve this., Please help. thanks
0
Comment
Question by:TrialUser
  • 3
  • 2
  • 2
7 Comments
 
LVL 4

Expert Comment

by:koolin
ID: 33438801
Best way is to probably put a wrapper div around that div and give it a image background that has the shadow effect.

You can't do it direct with CSS because not all browsers support it.

Here some example code and a link to example image below

div.bgMid is the wrapper div which includes a repeating (on the Y axis - vertical) background which serves as the shadow or fade for the inside div.

The the included image and code I was forcing the inside div to a width of 980px as that matches the wrapper background image.
div.bgMid {  width: 100%; margin: 0 auto; clear:both; background: url(images/bg_mid.png) repeat-y center center ; }

Open in new window

bg-mid.png
0
 
LVL 4

Expert Comment

by:koolin
ID: 33438805
eh wth here is the site I did that all for so you can see a full finished demo.

http://www.spmlearning.com/
0
 
LVL 9

Expert Comment

by:Snarfles
ID: 33440602
What you can do for ie browser is use this code

filter: glow(color=#000000,strength=3);

For real browsers you can use

text-shadow:0 0 5px #000000, -1px -1px 5px #000000;

This can be applied to div elements.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

by:TrialUser
ID: 33441056
Koolin:

Thanks for your response. DO you mean, there will be two divs nested?
I created two divs, it seems like the shadow div, is not wrapping around the main content div. what am i missng here? please help. thanks a ton again

<div class="shadow">
    <p>shadow</p><div class="page">
    <p>page</p>
    </div>
    </div>

body  
{
    background: #b6b7bc;
    font-size: .80em;
    font-family: "Helvetica Neue", "Lucida Grande", "Segoe UI", Arial, Helvetica, Verdana, sans-serif;
    margin: 0px;
    padding: 0px;
    color: #696969;
}

div.page
{
    width: 960px;
    background-color: #fff;
    margin: 0px auto 0px auto;
    border: 0px solid #496077;
}

div.Shadow
{  
      margin: 0 auto;
      clear:both;
      background: url(images/grayshadow.png) repeat-y center center ;
}
0
 
LVL 9

Assisted Solution

by:Snarfles
Snarfles earned 100 total points
ID: 33441095
Hi
Sorry I misread your question a bit.

You could try adding a dropshadow like this

http://www.webtoolkit.info/demo/css-drop-shadow

Instructions here

http://www.webtoolkit.info/css-drop-shadow.html

Just experiment with the border widths.

Cheers

Luke
0
 
LVL 4

Accepted Solution

by:
koolin earned 400 total points
ID: 33441331
Hey, see demo code below.  Only 2 changes I made was using the fade image I had "bg-mid.png" instead of your shadow one, and then the width of the page div to 980 to match the fade image.

If its still showing weird for you post a screenshot so I can see what is happening.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <style type="text/css">
        body
        {
            background: #b6b7bc;
            font-size: .80em;
            font-family: "Helvetica Neue" , "Lucida Grande" , "Segoe UI" , Arial, Helvetica, Verdana, sans-serif;
            margin: 0px;
            padding: 0px;
            color: #696969;
        }
        
        div.page
        {
            width: 980px;
            background-color: #fff;
            margin: 0px auto 0px auto;
            border: 0px solid #496077;
        }
        
        div.Shadow
        {
            margin: 0 auto;
            clear: both;
            background: url(images/bg-mid.png) repeat-y center center;
        }
    </style>
</head>
<body>
    <div class="Shadow">
        <div class="page">
            Content<br />
            <br />
            <br />
            Content<br />
            <br />
            <br />
        </div>
    </div>
</body>
</html>

Open in new window

0
 

Author Closing Comment

by:TrialUser
ID: 33441748
Thanks a ton for your help. It works great. thanks
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question