Take the 2-minute tour ×
Graphic Design Stack Exchange is a question and answer site for professional graphic designers and non-designers trying to do their own graphic design. It's 100% free, no registration required.

I feel like this looks ugly. The box shadow above the image blends really well with some images - generally with images that have a lot of color or are white - but with others it looks horrible.

example

The code:

box-shadow: 0 -2px 6px -2px rgba(0, 0, 0, .2);
border-top: 1px solid rgba(0, 0, 0, 0.2);

What would you guys recommend to fix this issue? As I can't exactly restrict what images are uploaded to the website, I would rather make it so everything looks great.

share|improve this question
add comment

4 Answers

up vote 4 down vote accepted

If you can set things up so that there's a 1 pixel transparent black stroke that's added to the interior of the image area, you mind find it works better with a wide variety of images.

Stroke

I used black at 40% opacity for the stroke in the examples above.

I don't know the best way to do this using CSS. Maybe a second div that's 1px smaller on all sides, with a border? There's probably quite a few methods you could use.

share|improve this answer
    
I like the stroke idea. Also note that the shadow is being cast up and down. Don't do that. If the OP moves the lighting to only cast downwards, the problem goes away. –  horatio Jun 5 '12 at 15:39
add comment

You could try to add a "frame" around the image by setting a 1px border (maybe the same grey as your outer border) and adding a 1px margin to create a separate white border between. This will appear as a "double" border, and with the white border part, it will make the shadow stand out in a way similar to the image where the background is already white.

Use rounded corners at top and square corners on bottom to make it follow the outer border.

Example for your image where I have just added the extra border:

Example with extra image border

The css code for the image would be something like this:

img.product_sample
{
  border: solid 1px rgba(0, 0, 0, 0.2);
  border-top-radius: 3px;
  margin: 1px; /* Causes the background color of the container work as an extra border */
}

An alternative is to just have the white border. This will give no visible difference to your original version when the image content background is white:

img.product_sample
{
  border: solid 1px white;
  border-top-radius: 3px;
  margin: 0px;
}
share|improve this answer
add comment

Hoping for a "generic" decoration like this that will work equally well with all possible shades and color of images is being a bit over-optimistic. The saving grace is that you probably aren't going to be showing these in isolation. The viewer will "get the idea" from the ones where the shadow is nicely visible and appealing, and will ignore it thereafter. It's the merchandise that is the focus of interest and what they'll be concentrating on.

In general, though, where you have to deal with highly variable items over which you have not control (and can't predict) it's best to keep things as simple as possible. You won't lose anything by omitting that top shadow completely, and you'll avoid the "blurry image" effect in your example.The shadow below works to give a little dimensionality to the "card," and you can control that background.

share|improve this answer
add comment

Try this CSS

box-shadow: 0 -2px 5px -2px rgba(0, 0, 0, 0.2);
border-top: 1px solid rgba(255, 255, 255, 0.75);
border-bottom: 1px solid rgba(0, 0, 0, 0.2);
border-right: 1px solid rgba(0, 0, 0, 0.1);
border-left: 1px solid rgba(0, 0, 0, 0.1);

this add a little inner-shadow to look better on darker background.

enter image description here

Working demo: http://jsfiddle.net/Sm97x/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.