【发布时间】:2022-05-10 21:22:01
【问题描述】:
如果使用 java 脚本,如何检查变换旋转?
getComputedstyle
【问题讨论】:
标签: javascript html css
如果使用 java 脚本,如何检查变换旋转?
getComputedstyle
【问题讨论】:
标签: javascript html css
这里是获取变换属性的示例...
这个问题是,你不会得到像 30deg 这样的东西作为从变换返回的东西,或者你得到一个矩阵......
这可以转换回你的度数->我想你最后想知道;)
further information about matrix and calculation
here 用于从矩阵中获取学位的在线计算器
var rotateStyle = window.getComputedStyle(document.querySelector('.rotate'), null);
alert(rotateStyle.transform);
.rotate {
display: inline-block;
transform: rotate(-90deg);
}
<span class="rotate">&lsaquo;3</span>
【讨论】:
在http://jsfiddle.net/ax5nM/108/ 中使用了box 类——直到现在用于检查translateX
var t=$(".box").css('transform').split(/[()]/)[1].split(',');
但也使矩阵的属性可访问。
矩阵代表的一些例子可以在这里找到:https://www.w3schools.com/cssref/playit.asp?filename=playcss_transform_matrix
【讨论】: