Solved

html div shadow effect

Posted on 2010-08-14
7
821 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

809 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