简体   繁体   中英

css transform matrix get left or top?

Calculation left or top ?

 <div style="width:100px;height:50px;"></div>
 div.style.transform = `rotateZ(45deg)`
 // 获取矩阵
 let transform = window.getComputedStyle(div)['transform'],
     matrix = transform.slice(7, -1).split(',')

To get matrix of a div with javascript, you can try to these

let style = window.getComputedStyle(div);
let transform = style.transform;
let matrix = transform.replace('matrix(', '').replace(')','').split(',')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM