日期:2014-05-16  浏览次数:20303 次

IE,Chrome获取div高度正常,FIrefox获取高度,总会高9px,有木有大侠指导一下
本帖最后由 whly348977787 于 2013-06-07 12:01:04 编辑

.divShow{
  float:left;
clear:left;
display: inline;
position: relative;
background-color: white;
margin-top: 3px;
padding:0px;
height:auto;
width:400px;
overflow:hidden;
border-top-color: #AAA;
border-top-style: solid;
border-top-width: 1px;
border-right-color: #AAA;
border-right-style: solid;
border-right-width: 1px;
border-left-color: #AAA;
border-left-style: solid;
border-left-width: 1px;
cursor:move;
}
.div_allso{
position:relative;
float:left;
display: inline;
margin-top: 3px;
width:10px;
height:100px;
background:url(../../newstyle/en/css/vicss/img/widgetbox/vcard-b.png);
background-position:-399px 0;
z-index:998;
margin-bottom:0px;
}


divShow是弹出框,里面有内容,然后撑开的,所以高度是动态获取的。
在IE,Chrome浏览器中获取[divShow]高度是206px,但是Firefox中获取的215px 就是不知道为什么多了9px.
我是在js中获取divShow高度,然后赋给div_allso,所以在Firefox中总是长9px.  
有木有大侠,知道这个是为什么?

------解决方案--------------------
你的高度不是height:auto;

很有可能说明问题不是在于height, 而是在于line-height

你设置一个固定的line-height:30px;

这样看看高度还会不会差.

另外,你没有完整的代码, 只能帮你到这里了
------解决方案--------------------
引用:
我这里也试了下,如果把html的文档声明给改成<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">,这样的话,就不会有9px的差别,但是现在的文档声明是<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" >,不知道这样对不对。。。第一次到加载页面,打开div,会有9px差别,但是第二次打开的的时候就不会有了。。。不知道为什么呢?

Quote: 引用:

你的高度不是height:auto;

很有可能说明问题不是在于height, 而是在于line-height

你设置一个固定的line-height:30px;

这样看看高度还会不会差.

另外,你没有完整的代码, 只能帮你到这里了


没有什么代码, 也不好怎么判断。 你可以在js中试一下, 把你要做的操作函数, 用setTimeOut 延迟一下

setTimeOut( function(){ xxxx(); }, 300 );