可以,使用 CSS 过滤器属性,即受 webkit 浏览器、Firefox 34 等现代浏览器支持Edge.
filter: drop-shadow(horizontal-offset vertical-offset blur-radius color);
.shadow { filter: drop-shadow(3px 3px 2px rgba(0, 0, 0, .7)); }
您也可以在 SVG 元素中使用此内容:
<svg> <rect class="shadow" x="10" y="10" width="200" height="100" fill="#bada55" /> </svg>
对于 Firefox 等浏览器
34、IE6,可以使用这个polyfill:// Usage: // $(element).cssShadow({horizontal-offset, vertical-offset, blur-radius, color}); $.fn.cssShadow = function(options) { // CSS syntax to include the units of the values var css = "-webkit-filter: drop-shadow(" + options.horizontalOffset + "px " + options.verticalOffset + "px " + options.blurRadius + "px " + options.color + ");"; // Applying the css return this.css({ 'filter': css, '-webkit-filter': css }); };
以上是CSS3 可以对 SVG 元素应用阴影吗?的详细内容。更多信息请关注PHP中文网其他相关文章!