Firefox and Chrome seem to render box-shadow quite differently

后端 未结 5 690
青春惊慌失措
青春惊慌失措 2021-01-17 11:00

I was testing a box-shadow effect in both Chrome and Firefox and I was surprised to see a drastic difference in rendering between the two browsers. Notably, Firefox\'s rende

5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-17 11:38

    You can create a media selector for Firefox which will be using a different style. You will have to play around with it. For example, I reduced the blur, the spread and turned up the opacity of the last inset box-shadow. So the CSS for the .box:hover should probably look something like this:

    .box:hover {
      box-shadow(0px 1px 3px rgba(0,0,0,0.3), inset 0px 4px 2px -2px rgba(255,255,255,0.7), inset 0px -3px 1px -2px rgba(0,0,0,0.3), inset 0px -20px 200px -100px rgba(0,0,0,0.5));
    }
    
    @-moz-document url-prefix() {
    .box:hover {
      box-shadow(0px 1px 3px rgba(0,0,0,0.3), inset 0px 4px 2px -2px rgba(255,255,255,0.7), inset 0px -3px 1px -2px rgba(0,0,0,0.3), inset 0px -20px 130px -120px rgba(0,0,0,0.9));
    }
    }
    

    For more media selectors and other browser hacks you can visit BrowserHacks.com

提交回复
热议问题