Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

apply drop shadow to border-top only?

How do you apply a drop shadow to a specific border edge?

For example, I have the following code:

header nav {     border-top: 1px solid #202020;     margin-top: 25px;     width: 158px;     padding-top:25px; } 

I want a drop shadow (1px 1px 1px #cdcdcd) applied only to border-top.

What's the best way to achieve this?

EDIT

This is essentially what I'm looking for

div {     border-top: 1px solid #202020;     margin-top: 25px;     margin-left:25px;     width: 158px;     padding-top:25px;     -webkit-box-shadow: 0px 1px 1px rgba(50, 50, 50, 0.75);     -moz-box-shadow:    0px 1px 1px rgba(50, 50, 50, 0.75);     box-shadow:         0px 1px 1px rgba(50, 50, 50, 0.75); } 

However, the shadow seems to be impacted by the padding. Is there anyway to attach the shadow to the border alone without adjusting the padding?

like image 481
AMC Avatar asked Mar 20 '12 18:03

AMC


People also ask

How do you apply box shadow only on top and bottom?

essentially the shadow is the box shape just offset behind the actual box. in order to hide portions of the shadow, you need to create additional divs and set their z-index above the shadowed box so that the shadow is not visible.

How do you add a shadow to only one side?

To apply a shadow effect only on one side of an element set the blur value to a positive number and set the spread value to the same size but with a negative sign. Depending on which side you want the shadow on, set the offset value as follows: Top shadow: offset-x: 0 and offset-y: -5px.

How do you set a box shadow only on the bottom?

Use the box-shadow Property to Set the Bottom Box Shadow in CSS. We can use the box-shadow property to set the shadow only at the bottom of the box. The box-shadow property sets the shadow of the selected element.

How do you get rid of shadow on one side?

1) Set your shadow's horizontal alignment to the left (negative values). box-shadow: -30px 0px 10px 10px #888888; Although this way you won't have the same shadow size in the top and bottom. 2) Use a div inside a div and apply shadow to each one.


1 Answers

Something like this?

div {    border: 1px solid #202020;    margin-top: 25px;    margin-left: 25px;    width: 158px;    height: 158px;    padding-top: 25px;    -webkit-box-shadow: 0px -4px 3px rgba(50, 50, 50, 0.75);    -moz-box-shadow: 0px -4px 3px rgba(50, 50, 50, 0.75);    box-shadow: 0px -4px 3px rgba(50, 50, 50, 0.75);  }
<div></div>
like image 167
danblundell Avatar answered Sep 28 '22 03:09

danblundell