有什么理由要使用CSS Box-shadow而不是drop-shadow? [英] Is there any reason to use css box-shadow over drop-shadow?

查看:129
本文介绍了有什么理由要使用CSS Box-shadow而不是drop-shadow?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设客户端兼容,那么在任何情况下CSS box-shadowfilter: drop-shadow更可取.

Assuming client compatibility, is there any situation where CSS box-shadow is preferable to filter: drop-shadow.

这篇文章看来,drop-shadowbox-shadow的硬件加速超集.这意味着我们基本上应该始终使用drop-shadow而不是box-shadow?

From the article it seems like drop-shadow is a HW accelerated superset of box-shadow. This means that we should basically always use drop-shadow instead of box-shadow?

推荐答案

box-shadowfilter: drop-shadow之间只有一个区别.使用box-shadow,您可以使用插入阴影,但不能使用filter: drop-shadow. 所有人都取决于您. 检查此示例.

There is only one difference between box-shadow and filter: drop-shadow. With box-shadow you can use inset shadows, but you can't do it with filter: drop-shadow. All depended on you. Check this example.

为什么最好使用由filter: drop-shadow插入的box-shadow?

Why is better to use box-shadow insted of filter: drop-shadow?

  • 更好的浏览器支持
  • 大多数开发人员都使用它
  • 更少的代码,更多的选择
  • 您可以使用嵌入式阴影
  • 您可以使用多个阴影

此外,还有一个带有图片的示例,其中最好使用filter: drop-shadow.第一个具有矩形阴影,但另一个具有跟随图像边缘的阴影.

Also, there is one example with image where is better to use filter: drop-shadow. The first one has rectangle shadow, but the other one has shadow which follow the edge of image.

这篇关于有什么理由要使用CSS Box-shadow而不是drop-shadow?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆