getComputedStyle获取css属性与IE下的currentStyle获取到的值不同
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了getComputedStyle获取css属性与IE下的currentStyle获取到的值不同,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含998字,纯文字阅读大概需要2分钟。
内容图文
![getComputedStyle获取css属性与IE下的currentStyle获取到的值不同](/upload/InfoBanner/zyjiaocheng/1083/4768d96993b44af8bfdd6f28f7854478.jpg)
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus?">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
<style>
.button {
height: 1em;
border: 0;
border-radius: .2em;
background-color: #34538b;
color: #fff;
font-size: 12px;
font-weight: bold;
}
</style>
</head>
<body>
<input type="button" id="button" class="button" value="点击我,显示高度" />
<script>
document.getElementById("button").onclick = function() {
//var oStyle = this.currentStyle? this.currentStyle : window.getComputedStyle(this, null);
var oStyle = this.currentStyle || window.getComputedStyle(this, null);//IE下获取是2em,Firefox下获取的是24px;浏览器默认1em=16px;
alert(oStyle.height);
};
</script>
</body>
</html>
原文:http://www.cnblogs.com/double405/p/4592796.html
内容总结
以上是互联网集市为您收集整理的getComputedStyle获取css属性与IE下的currentStyle获取到的值不同全部内容,希望文章能够帮你解决getComputedStyle获取css属性与IE下的currentStyle获取到的值不同所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。