首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SVG滤镜:不同的颜色取决于浏览器

SVG滤镜:不同的颜色取决于浏览器
EN

Stack Overflow用户
提问于 2019-05-08 04:23:32
回答 1查看 207关注 0票数 0

我有一个黑白图像,我正在尝试用SVG滤镜重新着色。Safari的颜色看起来比Chrome要暗得多,有没有办法让Safari看起来更像chrome呢?

CSS代码如下所示

代码语言:javascript
复制
.container-teamMembers a.six img {
    -webkit-filter: url(#duotone_bright_green);
    -moz-filter: url(#duotone_bright_green);
    -o-filter: url(#duotone_bright_green);
    -ms-filter: url(#duotone_bright_green);
    filter: url(#duotone_bright_green);
}

SVG过滤器是

代码语言:javascript
复制
<svg xmlns="http://www.w3.org/2000/svg" class="svg-filters">
<filter id="duotone_bright_green">
    <feColorMatrix type="matrix" result="grayscale" values="1 0 0 0 0
              1 0 0 0 0
              1 0 0 0 0
              0 0 0 1 0"></feColorMatrix>
<feComponentTransfer color-interpolation-filters="sRGB" result="duotone_blue_black">
<feFuncR type="table" tableValues="0.03137254902 0.74509803921"></feFuncR>
<feFuncG type="table" tableValues="0.007843137255 0.81568627451"></feFuncG>
<feFuncB type="table" tableValues="0.02352941176 0.0431372549"></feFuncB>
<feFuncA type="table" tableValues="0 1"></feFuncA>
</feComponentTransfer> 
</filter>
</svg>

谁能告诉我如何让Safari在Chrome上看起来更轻/更一致?

EN

回答 1

Stack Overflow用户

发布于 2019-05-08 09:00:37

这看起来似乎很愚蠢--但是将color-interpolation-filters="sRGB"移到filter元素而不是feComponentTransfer中- Safari在放入原语时似乎不会检查它。

下面是适用于我的过滤器。我在MacOS Mojave上运行Chrome73和Safari12.1,运行的是一台更老的Macbook Pro (2016)。

代码语言:javascript
复制
<svg xmlns="http://www.w3.org/2000/svg" class="svg-filters">
<filter id="duotone_bright_green" color-interpolation-filters="sRGB">
    <feColorMatrix type="matrix" result="grayscale" values="1 0 0 0 0
              1 0 0 0 0
              1 0 0 0 0
              0 0 0 1 0"></feColorMatrix>
<feComponentTransfer  result="duotone_blue_black">
<feFuncR type="table" tableValues="0.03137254902 0.74509803921"></feFuncR>
<feFuncG type="table" tableValues="0.007843137255 0.81568627451"></feFuncG>
<feFuncB type="table" tableValues="0.02352941176 0.0431372549"></feFuncB>
<feFuncA type="table" tableValues="0 1"></feFuncA>
</feComponentTransfer> 
</filter>
</svg>

这是屏幕截图- Chrome左边,Safari右边。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56029986

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档