Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

html div shadow effect

Posted on 2010-08-14
7
Medium Priority
?
848 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 400 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 1600 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: 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.

Question has a verified solution.

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

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
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.

916 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