tags:

views:

27

answers:

2

Hello all,

Let's say you have a website where the body's background color is red and a content area with a white background that is 1,000 pixels wide. Now let's say you want a drop shadow on the content area that is darkest at the juncture of the content area and the red background, and gets less opaque as it goes off the the left on the left side and the right on the right side. It basically looks like this:

sideways shadow

So my strategy is to make the background color of the body red and grab only the shadow in photoshop with a width of ~47px and a height of 1px. My question is:

How do I go about inserting that onto my website such that the browser's horizontal scroll bar only shows up when it's reached 1,000 pixels and not when it's reached 1,000 + 47 + 47 (the width of the content area plus the width of the two shadows).

I'm sure this is a common question, but I really suck at phrasing these things.

Thanks!

Edit: sorry for the lack of code. That's not usually my style. So here we go:

HTML:

<div id="mainwrapper">
    <div id="left_shadow"></div>
    <div id="right_shadow"></div>
</div>

CSS:

#mainwrapper {
    width:1000px;
    height:100%;
    margin-left:auto;
    margin-right:auto;
    background-color:#e8e8e8;
    position:relative;
}
#left_shadow {
    position:absolute;
    top:0;
    bottom:0;
    left:-47px;
    width:47px;
    background:url(/images/leftshadow.png) repeat-y;
}
#right_shadow {
    position:absolute;
    top:0;
    bottom:0;
    right:-47px;
    width:47px;
    background:url(/images/rightshadow.png) repeat-y;
}

With this setup, if I shrink the browser window down to 1,095 pixels, it doesn't have a horizontal scroll bar. If I shrink it to 1,094px, it has a horizontal scroll bar because it's recognize those absolutely positioned shadows as part of the content area. My question is: how do I make it so that the scroll bar only shows up when it hits the gray center (at 1,000px)? Thanks again, guys.

+1  A: 

Can the content area be 904px wide (1000-47-47) ? :P Afraid I'm going to need some code to help describe what you're talking about...

Steve
Sorry about that, Steve. I didn't think code would benefit here much, but I'll update the post shortly with an attempt at what I'm trying to do.
treeface
Leigh Shayler might have the right idea too, although not scale-able (will only work with `div` s as wide as the `jpg` is)
Steve
@Steve I've added the code to show you what I'm currently doing. Do you think it makes more sense to create a 1,094px wide by 1px high image with the 47px shadows on the left and right and nothing in the middle (where the content area covers it up)?
treeface
@Steve I appear to have figured it out! See my comment on Leigh's answer to see what I did. Thanks a lot for your help...upvote for your troubles :-]
treeface
Aight cheers mate
Steve
+2  A: 

<html>
<body style="background:url(bg.jpg) red repeat-y center top">
    <div align="center" width="100%" background="bg.jpg">
        <div style="width:870px;align:center;background:silver" align="center">test</div>
    </div>
<body>
</html>

The image below is small so you need to look closely :)

Sample Image

Leigh Shayler
Just noticed, its not going to have the correct centering and left behaviour.
Leigh Shayler
Hmmm...interesting. I've edited my post to better describe the problem. With this solution, would I have to make a 1094x1px image that is centered on the body's background? That actually sounds like it would work, but is that the best solution?
treeface
I just tried this and it works. To those interested, I set the background property of the body element to `background:#8b1c11 url(/images/long_shadow.png) repeat-y 50% 0%;` where long_shadow.png is 1094x1px. The 50% centers it on the page and bam...scroll bar only appears at 1,000px. Thanks Leigh!
treeface
Leigh Shayler