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!