The usage and difference of zoom attribute and scale attribute in CSS

Source: Internet
Author: User

Zoom Property

Grammar:

Zoom:normal | |

Default value: Normal

Apply to: all elements

Inheritance: Have

Take value:

Normal

Use the actual dimensions of the object.

   :

Use floating-point numbers to define the scaling scale. Negative values are not allowed

:

Use percentages to define the scaling scale. Negative values are not allowed

Description

Sets or retrieves the scaling ratio of the object.

The corresponding script attribute is zoom.

Scale Property

The value of the scale property is 2, which in itself is equivalent to a function because it is written as a function:

Scale ();

scale (x);

Scale (x,y);

1, scale (x,y) to scale the elements

X indicates a multiple of horizontal scaling y represents a scaling factor in the vertical direction

Y is an optional parameter and is not set, which means that the scaling multiples in the two directions of the x,y are the same. and take x as the subject.

Transform:scale (2,2.5);

2 . The ScaleX () element scales the element only in the x-axis (horizontal direction).

The default value is 1, the same as the base point at the center of the element. You can change the base point by Transform-origin.

Transform:scalex (2);

3 . The ScaleY () element scales the element only in the y-axis (vertical direction).

The central position of the element as the base point. You can change the base point by Transform-origin.

Transform:scaley (2);

Look at the compatibility notation:

CSS code copy content to clipboard

. test{

-moz-transform:scale (2,2);

-webkit-transform:scale (2,2);

-o-transform:scale (2,2);

Background:url (img/i.png) no-repeat;

width:198px;

height:133px;

}

The difference between zoom and scale

Zoom and scale These two things are used for scaling elements, but there are a few different places besides compatibility. Zoom scaling keeps the element in the upper-left corner, and scale by default is the middle position, which can be set by Transform-origin. In addition, they perform different rendering sequences zoom may affect the calculation of the box.

Run

 CSS Code copy content to clipboard

  1. <style>
  2. div {
  3. width:300px; height:100px;
  4. border:1px solid #CCC;
  5. font-size:0px;
  6. line-height:100px;
  7. margin:10px;
  8. }
  9. span {
  10. display:inline-block;
  11. height:80px; width:200px; background:#F5F5F5;
  12. vertical-align:Middle;
  13. overflow:hidden;
  14. }
  15. </style>
  16. <div>
  17. <span style="-webkit-transform:scale (0.5);" ></span>
  18. </div>
  19. <div>
  20. <span style="
  21. -webkit-transform-origin:top left;
  22. -webkit-transform:scale (0.5);
  23. "></span>
  24. </div>
  25. <div>
  26. <span style="zoom:0.5;" ></span>
  27. </div>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.