8

I have a CSS question; transform-origin is not working in firefox. The site is centered on chrome and safari, but not on firefox.

html {
transform: scale(0.9);
transform-origin: center top;
}

My site is http://test.lafsdesign.com/

I'd appreciate if you could help me fix this issue. Thank you so much in advance.

Full CSS

@media screen and (max-width: 1240px) {
html {
zoom: 0.9;
-moz-transform: scale(0.9);
-moz-transform-origin: center top;
}
}
@media screen and (max-width: 1140px) {
html {
zoom: 0.8;
-moz-transform: scale(0.8);
}    
}
@media screen and (max-width: 1005px) {
html {
zoom: 0.7; 
-moz-transform: scale(0.7);
}
}
@media screen and (max-width: 880px) {
html {
zoom: 0.6; 
-moz-transform: scale(0.6);
}
}

4 Answers4

15

In Firefox before 41.x with SVGs, it only works when fixed values are used:

-moz-transform-origin: 25px 25px;
-ms-transform-origin:  25px 25px;
-o-transform-origin: 25px 25px;
-webkit-transform-origin:  25px 25px;
transform-origin: 25px 25px;

Firefox won't handle relative values like 'center' or '50%'.

Hafenkranich
  • 1,696
  • 18
  • 32
4

Give percentage instead of position transform-origin: 0% 50%; for center top.. One More thing. transform-origin is not supported for SVG elements in Firefox. there are some workarounds for that. links: https://bugzilla.mozilla.org/show_bug.cgi?id=828286 Setting transform-origin on SVG group not working in FireFox How to set transform origin in SVG Hope it helps

Community
  • 1
  • 1
Khaleel
  • 1,212
  • 2
  • 16
  • 34
  • Khaleel, thanks, i have experienced right what you wrote, the transformation doesn't work for SVG parts in Firefox (54.0.1 (64-bit) on mac). – Rantiev Jul 10 '17 at 10:35
4

To fix this bug on Firefox, you can use : transform-origin: center; transform-box: fill-box;

yoanm
  • 66
  • 9
0

Transform origin is always a compatibility problem with certain browsers. That too when you use keywords such as center, top, bottom, left, right etc.

Try to give all the values in pixels. All the browsers would understand pixels perfectly. And if you are animating objects from random origin points, then you could go to a design environment and find the exact pixels where the origin has to be and code with the same exact value to be precise and compatible with all the browsers all time :)