Reputation: 13863
For an element with 100% width and box-shadow
defined such that it appears on the bottom only, how can I make the shadow appear consistent along the entire width of the element?
Currently, the shadow fades out at both the left and right edges; the shadow is noticeably different there than at the middle. Example:
<style>
body { padding: 0; margin: 0; }
h1 { margin: 0; box-shadow: 0 10px 10px #009;}
</style>
<h1>Bacon</h1>
Or see http://jsfiddle.net/RxVbt/1/.
Upvotes: 1
Views: 180
Reputation: 106
try this:
h1 { margin: 0; box-shadow: 0 2px 10px 8px #009;}
Example here
Upvotes: 0
Reputation: 21888
Add negative values for the end caps.
box-shadow: -5px -5px 10px 10px #009;
Upvotes: 0
Reputation: 71
I did this by changing the h1 to include
margin-left: -10px; margin-right: -10px; padding-left: 10px; padding-right: 10px;
The negative margin pulls the shadow wide enough to appear the same all the way across. This is a bit crude and hackish, but it works.
Upvotes: 3
Reputation: 25234
Add a spread distance to counter the blur value. For a blur of 10px you need a spread of 5px (5px in each direction = 10px) For example:
h1 { margin: 0; box-shadow: 0 5px 10px 5px #009;}
See http://jsfiddle.net/RxVbt/9/
Upvotes: 3