getComputedStyle获取css属性与IE下的currentStyle获取到的值不同
<!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: 2em;
line-height:24px;
//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>
最新文章
- struts-spring-mybatis实现最简单的登录验证
- position 属性和 z-index 属性对页面节点层级影响的例子
- Sharepoint中有关文件夹的操作
- HDU 1863 畅通工程(最小生成树,prim)
- 10.24 noip模拟试题
- Linux下samba的安装与配置
- 重新签名apk文件(手工用命令行)
- oracle_windows下命令启动oracle监听和服务
- hive union all 使用
- iOS 调试 之 打印
- golang sql database drivers
- [Leetcode]643. Maximum Average Subarray I
- WinForm客户端限速下载(C#限速下载)
- 原生js实现双向数据绑定
- 2019.3.22 JMeter基础操作
- A* 算法的原理
- PCIe 复位:Clod reset、warm reset、Hot reset、Function level reset
- python SQLite说一点点, python使用数据库需要注意的几点
- Android 编程下 Canvas and Drawables
- golang interface的使用和实现(翻译整理)
热门文章
- C语言控制台打印3D爱心图案
- 【iOS开发-33】学习手动内存管理临时抛弃ARC以及retain/assign知识——iOSproject师面试必考内容
- python oop面向对象笔记
- html5-表单常见操作
- unity, 不要用TextMesh,用图片代替
- Sublime Text 编辑器 插件 之 ";Sublime Alignment"; 详解
- redis源码学习_链表
- PHP学习笔记(10)mysql常用命令
- MapReduce编程实例4
- 用C/C++扩展你的PHP 为你的php增加功能