Make element behave same after css scaling

后端 未结 1 780
鱼传尺愫
鱼传尺愫 2021-01-17 00:41

I\'m manipulating divs with javascript all the time.

Sometimes I need to make those divs fit inside a container who\'s size is contantly changing.

One way to

相关标签:
1条回答
  • 2021-01-17 01:14

    The default transform-origin is 50% 50% (the middle of the element), so when you reduce the size of an element with scale, the edges are "retracted" from all sides towards the middle.

    enter image description here

    enter image description here

    so the top left corner appears to move down and to the right. But if you set the transform-origin to 0% 0% (top left) only the right and bottom sides move.

    enter image description here

    Hope this helps!

    0 讨论(0)
提交回复
热议问题