How to set the transform origin to a specific point on the element?

后端 未结 3 2015
萌比男神i
萌比男神i 2020-12-20 17:40

In this example I want to rotate the hammer from its bottom so is there a way to know exactly the right coordinates of a specific point on the element or should I randomly t

3条回答
  •  不思量自难忘°
    2020-12-20 18:23

    If you know you want to rotate from a specific point, ie: the bottom left. You can apply the transform origin using the following keywords;

    .hammer-icon {
        // x-offset y-offset 
        transform-origin: left bottom;
    }
    

    Further reference: https://developer.mozilla.org/en-US/docs/Web/CSS/transform-origin

提交回复
热议问题