getComputedStyle兼容
来源:互联网 发布:数据备份类型 编辑:程序博客网 时间:2024/06/14 05:54
兼容性
currentStyle //IE8及以下支持
getComputedStyle //IE8以上、FireFox、Chrome支持
使用方法
obj.currentStyle[attr]; //IE8及以下支持
window.getComputedStyle(obj,null)[attr]; //IE8以上、FireFox、Chrome支持;参数一:元素;参数二:伪类
JavaScript中访问元素的样式
javascript中,使用驼峰的形式取CSS属性,通过style对象取得style特性中指定的样式。
例:document.getElementById("box").style.backgroundColor; //读取背景色 读取元素的“内联样式
例:document.getElementById("box").style.backgroundColor = "red"; //设置背景的颜色为红色
float例外,因为float是保留字,不能用作属性名。
css-----------float
javascript----(1)cssFloat:FireFox、Safari、Opera和Chrome都支持;
(2)IE支持styleFloat。
标准模式下,所有度量值必须制定一个度量单位;混杂模式下,可以不写单位。
标准模式下不加单位会导致被忽略,所以最好都指定度量单位。
例:document.getElementById("box").style.width = "100px";//设置宽度为100像素
getComputedStyle
和 element.style的不同点
1、element.style
读取的只是元素的“内联样式”;getComputedStyle
读取的样式是最终样式,包括了“内联样式”、“嵌入样式”和“外部样式”。 2、
element.style
可读写,而 getComputedStyle只可读
。通常使用
getComputedStyle
读取样式,通过 element.style
修改样式。阅读全文
0 0
- getComputedStyle兼容
- currentStyle和getComputedStyle的兼容写法
- 实现浏览器兼容版的window.getComputedStyle
- getComputedStyle
- getComputedStyle
- getComputedStyle
- getComputedStyle
- 如何实现浏览器兼容版的window.getComputedStyle
- javascript中getComputedStyle和currentStyle的兼容写法
- currentStyle、getComputedStyle
- getComputedStyle && currentStyle
- javascipt:getComputedStyle()
- getComputedStyle无伪类
- getComputedStyle有伪类
- window.getComputedStyle
- getComputedStyle 使用方法
- document.defaultView.getComputedStyle
- document.defaultView.getComputedStyle
- SiteMesh页面装饰器的使用步骤
- python语言介绍
- Linux Ubuntu14.04 tensorflow安装
- 唯快不破:TCP/IP中的SO_REUSEADDR和SO_KEEPALIVE
- Cross Over to HTML5 Game Development.pdf 2017 英文原版 免费下载
- getComputedStyle兼容
- 表情显示隐藏
- Failed to push the item null解决方法
- docker私有仓库搭建与使用实战
- Redis 专栏(使用介绍、源码分析、常见问题...)
- The CLI Book.pdf 2017 英文原版 免费下载
- 【数据平台】sklearn库特征工程之数据预处理
- elasticsearch 特殊操作整理
- Practical Scala DSLs.pdf 2017 英文原版 免费下载