Home > Web Front-end > JS Tutorial > body text

Under IE: float attribute will affect the value of offsetTop_javascript skills

WBOY
Release: 2016-05-16 19:22:49
Original
1694 people have browsed it

Because I need to locate the height of an HTML element (for example: div) from the top of the page, I want to use offsetTop to get the value. However, I find that if float:left; is used in CSS, the value will be obtained. no the same.

Float:left is not used; the value obtained is the normal value of 200;
nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


The impact of Float on offsetTop



body {margin:0;padding: 0;}
#Top {height:100px;}
#Main {padding:100px;} #IECN {width:200px;height:50px;background:#f00;color:#fff;}



#Main {padding:100px;} does not use the float attribute, the value of offsetTop obtained Normal: 200.


Click here to try



nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Used float :left;, the value became 100, which was 100 less for no reason


The impact of Float on offsetTop







#Main {padding:100px;float:left;} uses the float attribute, The value of offsetTop obtained is only 100, which is 100 less for no reason.
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