【发布时间】:2020-06-22 01:32:11
【问题描述】:
我无法在 Firefox 中旋转 svg>pattern>图像。我的代码在 Chrome、Opera 和 Safari 中运行,我没有在 IE 中尝试。
这是一个例子:
function svgClick() {
document.getElementById('circle-image').style.transform = "rotate(180deg)"
}
body {
background-color: black
}
.circle {
stroke-width: 2.1;
stroke-dasharray: 200 200;
}
#circle-image {
transform-origin: 50% 50%;
transform: rotate(90deg);
}
h1 {
font-size: 20px;
color: white;
}
<svg width="58px" height="58px" onclick=svgClick()>
<pattern id="image" height="100%" width="100%">
<image x="10%" y="10%" width="20" height="20" id="circle-image" xlink:href="http://cliparting.com/wp-content/uploads/2016/05/Free-arrows-clipart-free-clipart-graphics-images-and-photos-image-2.png">
</pattern>
<linearGradient id="gradient">
<stop offset="0%" stop-color=" #40fffb " />
<stop offset="100%" stop-color=" #33468b" />
</linearGradient>
<circle cx="27.2" cy="27.2" r="17" fill="url(#image)" stroke="url(#gradient)" class="circle"></circle>
</svg>
<h1>Click on circle to rotate arrow to 180deg<h1>
【问题讨论】:
-
Firefox 中的模式目前仅支持变换属性,不支持 CSS 变换样式。
-
你能建议我可以做些什么来旋转它吗?