css - SVG 圆圈在 Chrome 中不起作用

标签 css google-chrome svg

我有这个 svg 代码。它在 Firefox 和 Safari 中运行良好。但出于某种原因,它没有出现在 Chrome 中。我不知道为什么...

<svg version="1.1" id="red_rgb" viewBox="0 0 100 56" xmlns="http://www.w3.org/2000/svg">
    <circle class="red" cx="50" cy="18" r="18"/>
    <circle class="green" cx="39" cy="37" r="18"/>
    <circle class="blue" cx="61" cy="37" r="18"/>
</svg>

和这个 CSS

.rgb_content    {
    width: 100%;
    height: 230%;
    position: absolute;
    left:0;
    top:12.5%; 
    z-index: 2;
    }       

.rgb_svg {
    position: absolute;
    z-index: 10;
}

circle.red {
    fill: red;
}

circle.green {
    fill: green;
}

circle.blue {
    fill: blue;
}   

circle.red, circle.green, circle.blue {
    mix-blend-mode: lighten;
}

.rgb_text {
    position: absolute;
    mix-blend-mode: hue;                
    z-index: 20;                
}

如前所述:它在 FireFox 和 Safari 中运行良好,但在 Chrome 中却不行。 我做错了什么?

最佳答案

这是因为“mix-blend-mode”not fully supported in Chrome for SVG

但是您可以在父容器上添加“隔离”到圆形容器(就像在 MDN 示例中一样):

/* without isolation, the background color will be taken into account */

svg {isolation: isolate;}
circle.red, circle.green, circle.blue {
    mix-blend-mode: lighten;
}

这实际上对我有用 (here is fiddle)

关于css - SVG 圆圈在 Chrome 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47951632/

相关文章:

javascript - 悬停样式和过渡不适用于 Firefox 中的附加元素

HTML 文本输入字段与同一类中的其他字段宽度不同

javascript - 使用 JavaScript 的交互式 SVG |嵌入还是不嵌入 SVG?

jquery - Chrome 扩展 : refuse header "date" in ajax request

javascript - 如何使用带序号的 d3.symbols

html - Internet Explorer 9 中的 SVG 打印

html - 输入对象上的 Bootstrap 表单内联图标不在末尾

jquery - 即使使用溢出 x :hidden,scrollTop 也无法工作

google-chrome - 从 chrome.storage 加载数据到 vue.js 数据

html - 从数据库中提取的 DIVS 和图像正常显示,但文本不显示