khurram
khurram

Reputation: 946

How to create shadow only left and right side, on a line?

i have a line of width: 15px; and height of 2px;
my question is, how to create the shadow only on right and left side?

Upvotes: 4

Views: 5247

Answers (4)

Adel
Adel

Reputation: 1468

        .box {
            height: 150px;
            width: 300px;
            margin: 20px;
            border: 1px solid #ccc;
        }

        .top {
            box-shadow: 0 -5px 5px -5px #333;
        }

        .right {
            box-shadow: -5px 0 5px -5px #333;
        }

        .bottom {
            box-shadow: 0 5px 5px -5px #333;
        }

        .left {
            box-shadow: 5px 0 5px -5px #333;
        }

        .all {
            box-shadow: 0 0 5px #333;
        }

in the body put..

    <div class="box top"></div>
    <div class="box right"></div>
    <div class="box bottom"></div>
    <div class="box left"></div>
    <div class="box all"></div>

Upvotes: 1

Rafael
Rafael

Reputation: 175

This fiddle has examples showing shadows only on:

  • Top and bottom
  • Left and right
  • Top

With that you should be able to do any kind of shadow.

http://jsfiddle.net/rafaelchiti/5jdHW/

The code:

div {
  margin-top: 20px;
  margin-left: 20px;    
  width: 100px;
  height: 100px;
}

.horizontal {
  box-shadow: 0px 15px 10px -11px rgba(0, 0, 0, .1) inset, 
              0px -15px 10px -11px rgba(0, 0, 0, .1) inset;  
}

.vertical {
  box-shadow: 0px 15px 10px -11px rgba(0, 0, 0, .1) inset, 
              0px -15px 10px -11px rgba(0, 0, 0, .1) inset;  
}

.one-side {
  box-shadow: 0px 15px 10px -11px rgba(0, 0, 0, .1) inset;
}

Hope this help.

Upvotes: 5

Libin
Libin

Reputation: 2462

CSS Box Shadow Add the following class to apply shadow. Check this jsfiddle example

.shadow {
  -moz-box-shadow:    3px 3px 10px 1px #000;
  -webkit-box-shadow: 3px 3px 10px 1px #000;
  box-shadow:         3px 3px 10px 1px #000;
}
  1. The horizontal offset of the shadow, positive means the shadow will be on the right of the box, a negative offset will put the shadow on the left of the box.
  2. The vertical offset of the shadow, a negative one means the box-shadow will be above the box, a positive one means the shadow will be below the box.
  3. The blur radius (optional), if set to 0 the shadow will be sharp, the higher the number, the more blurred it will be.
  4. The spread radius (optional), positive values increase the size of the shadow, negative values decrease the size. Default is 0 (the shadow is same size as blur).
  5. Color Hexadecimal color value.

Upvotes: 1

Mathew Thompson
Mathew Thompson

Reputation: 56429

Try this (based on the link you gave in your comment above):

box-shadow: 2px 2px 5px 2px rgba(0, 0, 0, 1);
-webkit-box-shadow: 2px 2px 5px 2px rgba(0, 0, 0, 1);

You can tweak it to how you like it using the CSS3 Generator

Upvotes: 3

Related Questions