有什么理由要使用CSS Box-shadow而不是drop-shadow? [英] Is there any reason to use css box-shadow over drop-shadow?
问题描述
假设客户端兼容,那么在任何情况下CSS box-shadow
比filter: drop-shadow
更可取.
Assuming client compatibility, is there any situation where CSS box-shadow
is preferable to filter: drop-shadow
.
从这篇文章看来,drop-shadow
是box-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-shadow
和filter: 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屋!