【问题标题】:Reading CSS height/width value are Xpx in FF while 'auto' in IE读取 CSS 高度/宽度值是 FF 中的 Xpx 而 IE 中的“自动”
【发布时间】:2010-11-17 02:19:18
【问题描述】:

Div 框尺寸使用 jQuery 测量,代码如下:

$(document).ready(function(){
  var h = $("#testbox").css("height");
});

在 FF 中它给我 270px,在 IE auto 中。如何在不更改其 css 的情况下测量 IE 中的实际 div 高度/宽度?​​

【问题讨论】:

    标签: javascript jquery css internet-explorer


    【解决方案1】:

    使用 .height() 和 .width()。

    var h = $("#testbox").height();
    var w = $("#testbox").width();
    

    【讨论】:

      【解决方案2】:

      尝试将 css 用于# testbox

      #testbox {
         height: 0px; 
      }
      

      【讨论】:

      • 没有。问题之一是:如何在不更改其 css 的情况下测量 IE 中的实际 div 高度/宽度?​​
      猜你喜欢
      • 1970-01-01
      • 2013-04-12
      • 2011-08-23
      • 2016-02-27
      • 1970-01-01
      • 2013-02-07
      • 1970-01-01
      • 2013-09-23
      • 2010-10-16
      相关资源
      最近更新 更多