CSS 'd' <路径> 属性在 Firefox 中不起作用

标签 css firefox svg

我有一个生成的代码,我不能直接修改,因为它是由一个巨大的 JS 代码生成的,它的一部分生成一个 svg 形状,我可以在 CSS 中覆盖它。但我的代码在 FF 中不起作用!!!

这里是原始代码:

<div id="map_outer" style="position: absolute; left: 3px; z-index: 1;">
<svg height="35" version="1.1" width="35" xmlns="http://www.w3.org/2000/svg" style="overflow: hidden; position: relative;"><desc style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">Created with Raphaël 2.1.0</desc>
<defs style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">
</defs>
<path fill="#cecece" stroke="#808080" d="M503.7,743.8C694,647.1999999999999,636.6,326.74999999999994,348.1,334.09V205.39L120.00000000000003,400.39L348.1,606.19V474.59000000000003C589,469.09000000000003,578,677.3900000000001,503.70000000000005,743.8900000000001Z" stroke-width="40" stroke-opacity="1" fill-opacity="1" transform="matrix(0.05,0,0,0.05,-1.9,-5.7)" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); stroke-opacity: 1; fill-opacity: 1; cursor: pointer;">
</path>
</svg>
</div>

这是我覆盖生成的“d”属性的 CSS 代码:

#map_outer svg path{
    fill: rgb(255, 204, 0) !important;
    d:path("M 850 300 C 850 300 350 300 350 300 L 348.1 205.39 L 120 400.39 L 348.1 606.19 L 350 500 C 850 500 850 500 850 500 z") !important;
    stroke-width: 0;
}

该代码在 Firefox 中不起作用。但适用于 Chrome。

enter image description here

最佳答案

var pathD = "M 850 300 C 850 300 350 300 350 300 L 348.1 205.39 L 120 400.39 L 348.1 606.19 L 350 500 C 850 500 850 500 850 500 z";

$("#map_outer svg path").attr("d", pathD);
#map_outer svg path{
    fill: rgb(255, 204, 0) !important;
    d:path("M 850 300 C 850 300 350 300 350 300 L 348.1 205.39 L 120 400.39 L 348.1 606.19 L 350 500 C 850 500 850 500 850 500 z") !important;
    stroke-width: 0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="map_outer" style="position: absolute; left: 3px; z-index: 1;">
<svg height="35" version="1.1" width="35" xmlns="http://www.w3.org/2000/svg" style="overflow: hidden; position: relative;"><desc style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);-moz-tap-highlight-color: rgba(0, 0, 0, 0);">Created with Raphaël 2.1.0</desc>
<defs style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);-moz-tap-highlight-color: rgba(0, 0, 0, 0);">
</defs>
<path fill="#cecece" stroke="#808080" d="M503.7,743.8C694,647.1999999999999,636.6,326.74999999999994,348.1,334.09V205.39L120.00000000000003,400.39L348.1,606.19V474.59000000000003C589,469.09000000000003,578,677.3900000000001,503.70000000000005,743.8900000000001Z" stroke-width="40" stroke-opacity="1" fill-opacity="1" transform="matrix(0.05,0,0,0.05,-1.9,-5.7)" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); stroke-opacity: 1; fill-opacity: 1; cursor: pointer;">
</path>
</svg>
</div>

关于CSS 'd' <路径> 属性在 Firefox 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42229169/

相关文章:

html - "infamous"CSS : 2 divs side-by-side, 跨浏览器版本(?)

html - 为什么这个 CSS 代码使我的下拉菜单只显示 3 个元素中的一个?

javascript - 根据相邻元素的大小或值隐藏 flexbox 元素

javascript - 使用相对的 SVG 宽度和高度在中心节点周围均匀分布节点

html - 与 IMG 标签相比,将 SVG 代码加载到 HTML 中是否未优化或速度较慢?

java - 如何更改 MenuItem 焦点/悬停颜色

javascript - 使用javascript读取mozilla firefox的 "about config"首选项

internet-explorer - 发送邮件到 : form 时对邮件正文的限制

html - HR 在 Firefox 中显示不同

javascript - 如何迭代路径元素并对每个元素进行动画处理?