Box-Shadow on the left side of the element only

61

I have been having trouble setting a box shadow on the left side of an element only.

I tried this:

box-shadow: -10px 0px 3px 0px #aaa;

However, the box shadow looks more like a grey line and lacks the regular shadow-effect that I am used to when using box-shadow. Also, the above example includes a small top box-shadow that I am trying to get rid of.

Thank you

This question is tagged with css

~ Asked on 2012-05-05 15:19:30

The Best Answer is


96

You probably need more blur and a little less spread.

box-shadow: -10px 0px 10px 1px #aaaaaa;

Try messing around with the box shadow generator here http://css3generator.com/ until you get your desired effect.

~ Answered on 2012-05-05 15:29:50


3

This question is very, very, very old, but as a trick in the future, I recommend something like this:

.element{
    box-shadow: 0px 0px 10px #232931;
}
.container{
    height: 100px;
    width: 100px;
    overflow: hidden;
}

Basically, you have a box shadow and then wrapping the element in a div with its overflow set to hidden. You'll need to adjust the height, width, and even padding of the div to only show the left box shadow, but it works. See here for an example If you look at the example, you can see how there's no other shadows, but only a black left shadow. Edit: this is a retake of the same screen shot, in case some one thinks that I just cropped out the right. You can find it here

~ Answered on 2019-12-18 22:04:31


Most Viewed Questions: