The difference between zoom and scale in CSS

Source: Internet
Author: User

zoomAndscaleThese two things are used to scale the elements, but there are a couple of different places in addition to compatibility.zoomZooming keeps the element in the upper-left corner, while thescaleThe default is the middle position, which can betransform-originTo set. In addition, they perform different rendering orders.zoomMay affect the calculation of the box.
Run<! DOCTYPE html>
<style>
div {
Width:300px;Height:100px;
Border:1pxSolid#CCC;
Font-size:0px;
Line-height:100px;
Margin:10px;
}
span {
Display:Inline-block;
Height:80px;width:200px;background:#F5F5F5;
Vertical-align:Middle;
Overflow:Hidden;
}
</style>
<div>
<spanstyle="-webkit-transform:scale (0.5);"></span>
</div>
<div>
<spanstyle="
-webkit-transform-origin:top left;
-webkit-transform:scale (0.5);
"></span>
</div>
<div>
<spanstyle="zoom:0.5;"></span>
</div>

The first test only sets thescale, and the elements are scaled based on their own center point. The second Test not only sets thescaleAnd alsooriginTo set the base point of the zoom to the upper-left corner, so the element stays in the upper-left corner after the change is over. Although the container is set to the same height as the High Line, when it is not centered in the container, becausescaleIs the first layout after the transformation, the transformation will not affect the layout. The last test is to use thezoom, although not supported on Firefox, this is a very old feature. The difference between it and the second test is that it scales first, then calculates the layout. So in the example it gets the vertical center effect.

Differences between zoom and scale in CSS

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.