width/height after transform

前端 未结 5 1407
予麋鹿
予麋鹿 2020-11-27 16:00

How do I retrieve the width and height properties after I\'ve applied transform: rotate(45deg);?

Like, 11x11 square after rotation becomes 17x17 (Chrome

5条回答
  •  离开以前
    2020-11-27 16:23

    I'm writing this answer since you have tagged JQuery.

    Jquery takes in to consideration the transform factors when calculating dimensions.

    So, if you use

    $('mySelector').width()
    

    it will give you the actual width. Same goes with height(), left() and top()

提交回复
热议问题