内容简介:当一个css属性在JavaScript中对应的名字是保留字时,在之前加“css”前缀来创建合法的CSSStyleDeclaration名字。CSSStyleDeclaration对象的cssText属性可以用来设置style对象的值。所有的定位属性都必须包含单位。
当一个css属性在JavaScript中对应的名字是保留字时,在之前加“css”前缀来创建合法的CSSStyleDeclaration名字。
CSSStyleDeclaration对象的cssText属性可以用来设置style对象的值。
所有的定位属性都必须包含单位。
查询计算出的样式
getComputedStyle(element,null或空字符串或伪类)(非IE,返回CSSStyleDeclaration对象), currentStyle(IE,返回CSSStyleDeclaration对象)
classList属性,
add() remove()从元素的class属性中添加和清除一个类名。 toggle()表示如果不存在类名就添加一个;否则,删除它。 contains()方法检测class属性中是否包含一个指定的类名。 replace()用一个新类替换已有类。
开启和关闭样式表
document.styleSheets[0].disabled=false;
脚本化样式表
document.styleSheets[]数组的元素是CSSStyleSheet对象,CSSStyleSheet对象有一个cssRules[]数组,它包含样式表的所有规则。IE中使用rules代替cssRules。
标准的API接口定义了insertRule()和deleteRule()方法来添加和删除规则。
IE定义了大致等效的函数addRule()和removeRule()。仅有的不同是addRule()希望选择器文本和样式文本作为两个参数。
CSSStyleRule对象,selectorText,cssText,parentRule,parentStyleSheet,style,styleMap,type
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Handbook of Data Structures and Applications
Dinesh P. Mehta / Chapman and Hall/CRC / 2004-10-28 / USD 135.95
In the late sixties, Donald Knuth, winner of the 1974Turing Award, published his landmark book The Art of Computer Programming: Fundamental Algorithms. This book brought to- gether a body of kno......一起来看看 《Handbook of Data Structures and Applications》 这本书的介绍吧!