Tips’n’tricks: CSS float in JavaScript
The CSS float property it is often used (if you don’t layout your pages with evil pages). It is pretty easy to setup using CSS code:
float: left;
.
If you want to setup a CSS property from JavaScript it is usually done using the syntax:
element.style.property = value;
and -
signs are replaced with camel case (e.g. backgroundColor
instead of background-color
).
This won’t work for float
too. float
is a reserved JavaScript word, so you should use cssFloat
instead. As usual ;), Internet Explorer is special and you should use styleFloat
instead.
That’s it. Short small tip, but very useful if you want to dynamically modify the flow of elements.
Categories: Web
css, javascript, Web
This is the same with property className which refers to the class attribute (as class it is a reserved JavaScript word)
Hello webmaster
I would like to share with you a link to your site
write me here preonrelt@mail.ru