CSS 剪辑路径在带有子元素/伪元素的 Safari 中不起作用
我有一个非常基本的 SVG 剪辑路径:
<svg width="0" height="0">
<defs>
<clipPath id="line">
<path d="..." />
</clipPath>
</defs>
</svg>
我想使用它与 CSS:
div {
clip-path: url(#line);
&:before {
...
}
}
它在 Google Chrome 上运行良好,但在 Safari 中根本不显示。
还尝试添加 -webkit-
前缀。
这是一个现场演示:https://jsfiddle.net/1dtpLg8y/
如果您删除 :before
元素,它实际上会起作用: https://jsfiddle.net /fp5mouLn/
这是一个仅适用于 SVG 的版本: https://jsfiddle.net/3gt67cLh/1/ 但会喜欢用 CSS 来做这件事。
在 Safari 中不显示任何内容。
I got a pretty basic SVG clip-path:
<svg width="0" height="0">
<defs>
<clipPath id="line">
<path d="..." />
</clipPath>
</defs>
</svg>
Which i wanna use w/ CSS:
div {
clip-path: url(#line);
&:before {
...
}
}
It's working fine with Google Chrome, but not showing at all in Safari.
Also tried adding the -webkit-
prefix.
Here's a live demo: https://jsfiddle.net/1dtpLg8y/
Its actually working if you get rid of the :before
element: https://jsfiddle.net/fp5mouLn/
Here's a working SVG only version: https://jsfiddle.net/3gt67cLh/1/ but would love to do this with CSS.
Not showing anything in Safari.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将
overflow:hidden
添加到行 div 似乎可以解决此问题。(在 iOs safari 上测试)
Adding
overflow:hidden
to your line div seems to solve this issue.(tested on iOs safari)
如果herrstrietzel的解决方案不起作用,请尝试“filter:hue-rotate(0deg);”
我遇到了类似的问题,添加“overflow:hidden”不起作用,但添加“filter:hue-rotate(0deg)”却起作用。
If herrstrietzel's solution does not work, try "filter: hue-rotate(0deg);"
I had a similar problem, and adding "overflow:hidden" did not work, but adding "filter: hue-rotate(0deg)" did.