Home >Web Front-end >JS Tutorial >Special writing method to operate CSS float attribute under javascript_javascript skills

Special writing method to operate CSS float attribute under javascript_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:09:41939browse

There are certain rules for using js to operate css attributes:

1. For css attributes without an underscore, generally use the style. attribute name directly.
Such as: obj.style.margin, obj.style.width, obj.style.left, obj.style.position, etc.

2. For CSS attributes containing underscores, remove each underscore and change the first character after each underscore to uppercase.
Such as: obj.style.marginTop, obj.style.borderLeftWidth, obj.style.zIndex, obj.style.fontFamily, etc.

I think most front-end developers are familiar with this rule. There is a special attribute in css and its js usage method is indeed quite special.
This special attribute is: float. We cannot use obj.style.float directly, as this operation is invalid.

The correct usage method is: IE: obj.style.styleFloat, other browsers: obj.style.cssFloat.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn