[英]how to get the #perspective div's style transform perspective-origin property
this is css i am trying to get the perspective-origin 这是CSS,我正在尝试获取透视图起源
#perspective {
width: 200px;
height: 200px;
margin: 75px 0 0 75px;
border: 1px solid black;
transform:perspective-origin(center center);
}
this js i try to get the perspective-origin and i want to get the value but no work ye 这个js,我尝试获取透视图源,我想获取值,但是没有用
function getCssProperty(ele, property) {
var id = document.getElementById(ele);
return
window.getComputedStyle(id, null).getPropertyValue(property);
}//this is first class perspective and property transform
console.log(getCssProperty('perspective', 'transform'));
This will do the trick. 这将达到目的。 I will investigate transform:perspective-origin(center center); 我将研究transform:perspective-origin(center center); vs perspective-origin: center center; vs透视图起源:居中居中;
<!DOCTYPE html>
<html>
<head title="StackO">
<script src="~/Scripts/jquery-1.9.1.min.js"></script>
<style>
#perspective {
width: 200px;
height: 200px;
margin: 75px 0 0 75px;
border: 1px solid black;
/*transform: perspective-origin(center center); this is not valid for the transform property;*/
perspective-origin: center center;
}
</style>
<script src="~/Scripts/jquery-1.9.1.min.js"></script>
</head>
<body>
<div id="output"></div>
<input type="button" id="target" value="getEvt" />
<div id="perspective"></div>
<script type="text/javascript">
function getCssProperty(ele, property) {
var id = document.getElementById(ele);
var prop =
window.getComputedStyle(id, null).getPropertyValue(property);
return prop;
}
$("#target").click(function () {
var prop = getCssProperty('perspective', 'perspective-origin');
$("#output").html(prop);
});
//console.log(getCssProperty('div2', 'role'));
</script>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.