Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS non-standard "ZOOM" property

Tags:

css

I have a css file with a class with zoom: 1.

I get the following error on the browser console.

This page uses the non-standard "zoom" property. Instead, you can use calc (), or "transform" together with "transform-origin: 0 0".

How do you convert the property from zoom to transform or calc? ThankYou

like image 901
Francesco Tozzi Avatar asked Dec 25 '19 09:12

Francesco Tozzi


People also ask

What is Zoom property in CSS?

The zoom property in CSS allows you to scale your content. It is non-standard, and was originally implemented only in Internet Explorer. Although several other browsers now support zoom, it isn't recommended for production sites. .zoom { zoom: 150%; }

How do I stop a CSS layout from distorting when zooming in out?

To fix the problem with zooming in, try adding the min-width attribute to your outer countainer ( #container or #navbar ?). Setting min-width prevents the webpage from trying to shrink down beyond the specified width (i.e. 300px).


1 Answers

You can find a description and recommendation on the MDN web docs:

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.

recommendation:

The non-standard zoom CSS property can be used to control the magnification level of an element. transform: scale() should be used instead of this property, if possible. However, unlike CSS Transforms, zoom affects the layout size of the element.

demo:

div.t1 {
  zoom: 0.5;
}
div.t2 {
  transform:scale(0.5);
  transform-origin: 0 0;
}
<div class="t1">Hello World</div>
<div class="t2">Hello World</div>
like image 56
Sebastian Brosch Avatar answered Oct 01 '22 00:10

Sebastian Brosch