1.float样式属性在DOM2中的变化
在DOM2级中规定float样式属性的访问方式可以是:cssFloat(chrom、Firefox)、styleFloat,但是也可以直接使用float来访问float样式属性
2.style:就是CSSStyleDeclaration即我们常获取的style对象
3.selectorText:样式规则的选择器 如:#box
4.insertRule(规则字符串,位置):
<!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title>demo</title> <style> #box{ width:200px; height: 200px; background-color: #2c82c9; } body{margin: 0px; padding: 0px;} </style> <link type="text/css" rel="stylesheet" href="edit/css/font-awesome.css"> </head> <body> <div id="box">fsfdsf</div> </body> <script> var sheet=document.getElementsByTagName("style")[0].sheet; insertRule(sheet,"#box","background-color:red",sheet.cssRules[0].style.length-1); function insertRule(sheet, selectorText, cssText, position){ if (sheet.insertRule){ //chrom 、firefox sheet.insertRule(selectorText + "{" + cssText + "}", position); } else if (sheet.addRule){ //IE sheet.addRule(selectorText, cssText, position); } } </script> </html> 5.deleteRule(样式属性位置) //chrom、firefox 或 removeRule //ie
4.ownerNode:样式表对应的元素节点对象,一般指style和link
备注:获取CSSStyleSheet对象的方式是:先获取style或link元素节点对象,然后使用sheet(chrom、firefox)或styleSheet(IE)直接获取到