简体   繁体   English

在Firefox中忽略了SVG中心的CSS转换起源

[英]CSS transform-origin from center on SVG ignored in Firefox

I have an svg icon inlined in my html that when hovered, applies a css scale transform. 我的html内嵌了一个svg图标,当悬停时,应用css scale变换。 I've set the transform-origin property to center/50% on the path's parent group* and it works great in Webkit but ignored in Firefox. 我已经将transform-origin属性设置为路径的父组*的中心/ 50%,它在Webkit中运行良好但在Firefox中被忽略。 Any ideas? 有任何想法吗?

Here is a jsFiddle 这是一个jsFiddle

HTML/SVG: HTML / SVG:

<div class="col3 build websites-content">
    <svg class="svg-icon icon-build" width="75px" height="75px">
        <g><path fill="#fff" d="M17.5,39.7L28.8,42v13.5l9.5-8.5L49,55.5l4.5-36L17.5,39.7z M35.5,42L31,48.7V42l18-18L35.5,42z"/></g>
    </svg>
</div>

CSS (ignoring vendor prefixes): CSS(忽略供应商前缀):

.websites-content g {
    transition: transform 0.3s ease;
    transform-origin: center center;
}

.websites-content:hover g {
    transform: scale(1.3);
}

*I have other icons containing several paths, necessitating a group – just using this single path example for clarity *我有其他图标包含几个路径,需要一个组 - 为了清楚起见,只使用这个单一路径示例

I managed to make it work on both using translate to compensate the translation caused by scaling: 我设法使用translate来补偿由缩放引起的翻译:

.websites-content:hover g {
 -webkit-transform: scale(1.3) translate(-8.6px, -8.6px);
 -moz-transform:    scale(1.3) translate(-8.6px, -8.6px);
 -ms-transform:     scale(1.3) translate(-8.6px, -8.6px);
  transform:        scale(1.3) translate(-8.6px, -8.6px);
}

jsfiddle 的jsfiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM