Zoom Vs. Scale in CSS3
zoom
is not standard css feature.
from MDN:
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.
Use transform: scale(0.8)
instead.
Complementary to Drkawashima's answer:
zoom
doesn't work in Firefox at all. See caniuse- Once upon a time (fairy tale ends here sorry),
zoom: 1;
was the mighty declaration that helped to debug IE6. It conferred the element it was applied an internal "switch" to this browser named hasLayout (not a CSS property, just a concept like "clearfix" is). You'll findposition: relative; zoom: 1;
quite a lot in old projects
zoom
does not work with css animations or transition
propriety:
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_animated_properties
Transform is more predictable than zoom across browsers.
Zoom affects positioning differently in different browsers.
example:
position:absolute; left:50px; zoom: 50%;
- IE will not change the
left
value at all. - Chrome will change the left value to
25px
. Effectively it does doleft = left * zoom
. But DevTools Computed Values in DevTools will still displayleft: 50px
, even though that is effectively not true due to the zoom.
Transform is handled the same way in all browsers (as far as I can tell).
example:
position:absolute; left:50px; transform: scale(0.5)
left
would effectively be set to25px
in both Chrome and IE. (again, computed values will still not reflect this, it will displayleft:50px
)- To avoid changing the
left
value, simply usetransform-origin: 0 0
. That will ensure left is still 50px.
Demo: http://jsfiddle.net/4z728fmk/ shows 2 boxes where the small one is zoomed or scaled to 50%. Looks like this:
edit: img updated 2016-06-16 with Firefox (nothing had change in Chrome or IE since last time)