transform:scale vs traditional resizing

痞子三分冷 提交于 2020-01-06 13:42:23

问题


Are there any drawbacks of using transform: scale(x.x) instead of doing traditional resizing with the width and height properties? Does scaling produce a lower quality image or something?


回答1:


Scale generates a general better quality result (from a visual point of view) because many browsers render it via GPU (in other words, with hardware acceleration) using advanced resampling algotithms, but it has a drawback:

Scaled object does not create a space around it, larger than its original size.

Practically.... Browsers' behaviour is the following (approximately):

  1. Render of the object "A" in its original size
  2. Placing of other objects around it (until this point browsers completely ignore scale rule declaration)
  3. At the end, "visually" scaling of "A", overlapping others like it would be in a different layer



回答2:


transform:scale(); will not expand or shrink initial space used by your element.

a 100px square may look 200px , but will still use 100px² on screen . it will overlap what's around.



来源:https://stackoverflow.com/questions/22970886/transformscale-vs-traditional-resizing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!