日期:2014-05-17  浏览次数:20497 次

js操作css的规则

书写规则:

?

1、没有中划线的css属性,直接使用“style.属性名”即可。
如:obj.style.width,obj.style.left 等。

?

2、含有中划线的css属性,去掉中划线并将中划线后的那个字符大写即可。
如:obj.style.zIndex,obj.style.fontFamily 等。

?

3、特殊属性:float,不能直接使用obj.style.float,这样操作是无效的。正确的使用方法是:IE:obj.style.styleFloat,其他浏览器:obj.style.cssFloat。