Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS box shadow top-only in mozilla?

Tags:

css

firefox

I have a footer on my web site, and I'd like to have a subtle shadow cast above it. The CSS looks like this:

div.footer {
  -webkit-box-shadow: 0px 0px 7px $dark2;
  -moz-box-shadow: -7px 0px 7px $dark2;
  box-shadow: 0px 0px 7px $dark2;
}

As I'm sure you're all familiar, Mozilla extends pages to render the full extent of a box shadow, which is a problem if you have elements extending 100% wide, such as my footer.

I've already tweaked the moz declaration to prevent horizontal scrollbars, (I did this on my menubar on my site as well), but when I put this on my footer I found that Mozilla extends the page 7px past the footer on the bottom now. I was surprised by this because it doesn't extend the page vertically past the menubar at the top of the page...

So, has anyone got a solution for rendering a top-only box-shadow in Firefox?

EDIT: See a fiddle of this at: http://jsfiddle.net/burlesona/2LwXa/

like image 579
Andrew Avatar asked Mar 20 '11 22:03

Andrew


People also ask

How do you put a box shadow on top in CSS?

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 I set the box shadow on the bottom only?

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 put a box shadow on all sides in CSS?

box-shadow: h-shadow v-shadow blur spread color inset; In your example you're offsetting shadow by 10px vertically and horizontally. Like in other comments set first two values to 0px in order to have even shadow on all sides.

Can you have two box shadows CSS?

If your browser supports Css Box Shadow Property then you can see multiple colored shadows below. Multiple shadows can be made using the same code that is used for making single shadow. To make these multiple shadows we just need to define multiple shadow value and seperate them with a comma.


1 Answers

Try box-shadow: 0px -7px 7px -7px #333;.

The fourth value is the spread of the shadow. Negative values cause the shadow to shrink. Combined with the blur, it results in a shadow with the same size as the element, which the offset-y then moves in to view.

like image 94
Neil Avatar answered Nov 18 '22 03:11

Neil