-->

CSS Firefox box-shadow and outline

2020-08-22 06:58发布

问题:

I've added both outline and box-shadow to a div in my CSS code.
The div looks great on Chrome and IE but not in Firefox:
Chrome and IE: http://i.phirune.com/csrjfyqoczob

FireFox: http://i.phirune.com/4gsrrub3ww6e

The CSS code is as follows:

#container {
width:960px;
margin:0px;
padding:0px;
margin-left:auto;
margin-right:auto;
margin-top:-10px;
background-color: #415475;
-moz-box-shadow: 0 0 25px 25px rgba(0,0,0,0.2);
-webkit-box-shadow: 0 0 25px 25px rgba(0,0,0,0.2);
box-shadow: 0 0 25px 25px rgba(0,0,0,0.2);
outline:#000000 solid thick;
}

I have no idea how to fix this, any insight will be appreciated.

回答1:

Why not use multiple box-shadows? Just separate your box-shadows by commas.

box-shadow:
    0px 0px 0px 1px #fff,
    0px 0px 0px 2px #606054,
    0px -1px 9px 1px rgba(119, 119, 119, 0.4);

You can add as many has your heart desires.



回答2:

This is a Firefox bug. You can only get around it. The ticket is still live, you may see at: https://bugzilla.mozilla.org/show_bug.cgi?id=480888



回答3:

-moz-box-shadow: 1px 1px 10px #00f;
-webkit-box-shadow: 1px 1px 10px #00f;
box-shadow: 1px 1px 10px #00f;

What browser versions are you attempting to support? Modern browsers support css3 and you don't need to do the css hacks.

here's some css3 documentation for drop shadows: http://www.css3.info/preview/box-shadow/



标签: css firefox