Yesterday encountered a use JS to change the element floating, then directly wrote the obj.style.float= "left"; the results did not work; After checking the information to find that can not be written, now to organize several styles of writing
1, directly write CSS properties, such as: obj.style.height/width/color/position, etc.
2, to change the capitalization, such as: Obj.style.fontsize/marginleft/backgroundcolor, etc.
3,float, this property is used in IE with obj.style.stylefloat= "left";
Obj.style.stylefloat= "left" in other browsers such as FF;
Third compatibility wording: obj.style[' cssfloat ' in Obj.style? ' Cssfloat ': ' stylefloat ']= ' left '; specific examples are
1 <styletype= "Text/css">2 #content{3 width:1000px;4 margin:0 Auto;5 background:#66c;6 Overflow:Hidden;7 }8 #left{9 width:200px;Ten Height:50px; One background:#c66; A Color:#fff; - } - </style>
1 <DivID= "Content">2 <DivID= "Left">Left</Div>3 <DivID= "Main">Main</Div>4 </Div>
1 <Scripttype= "Text/javascript">2 varOleft=document.getElementById (' Left');3 oleft.style['cssfloat' inchOleft.style?'cssfloat':'stylefloat']=' Left';4 </Script>
This changes the float property with ID to left by JS
JavaScript change style (cssfloat,stylefloat)