Home > Web Front-end > JS Tutorial > How to use js to control float code in css_javascript skills

How to use js to control float code in css_javascript skills

WBOY
Release: 2016-05-16 19:10:07
Original
1031 people have browsed it

IE uses styleFloat
and others uses cssFloat


This article briefly introduces the special writing method of JS to operate the float attribute of CSS. For CSS attributes containing underscores, each underscore Just remove and capitalize the first character after each underscore.

Js style float

Special writing method for JS to operate the float attribute of css

There are certain rules for using js to operate the css attribute:

1. For css attributes without underscores, 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 replace the first character after each underscore with uppercase letters.

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. But there is a special attribute in css whose usage in js is quite special. This special attribute is: float. We cannot use obj.style.float directly, as this operation is invalid. The correct usage of

is: IE: obj.style.styleFloat, other browsers: obj.style.cssFloat.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template