How to solve Firefox's 0 when using offsetheight to get div height

Source: Internet
Author: User
Firefox in need to get the height of p, often need to use offsetheight, sometimes encounter offsetheight get to 0 phenomenon, below for everyone to introduce the more practical solution, interested friends can refer to the next

When you need to get the height of p, Firefox often needs to use offsetheight, and sometimes encounter the phenomenon that offsetheight gets to 0,

In the use of IE or Firefox, especially in the current p+css way, often do not define the height of p, which is to add p content, need to obtain the height of p, often need to use the offsetheight.

In use, sometimes encounter offsetheight get to 0 phenomenon, but if you use a variety of JS debugging tool debugging, but also can see the value in the object (if the direct point to offsetheight is not value, but if the object view is a value, Enter the object in the debugger to see that the object has been refreshed, so there is a value. )

such as the following fragment

The code is as follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> 

If you get the height of the PCJ, you get 0 in onload. Because the PCJ under the float way layout.

At this point, if P is simple, you can use the hidden layer, such as the pcj2 here, the float is removed, the height obtained is as high as the PCJ.

One key point here is that the float layout is no problem in IE, but for Firefox it takes 0.

The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.