【问题标题】:Why IE8 doesn't understand my css为什么 IE8 不理解我的 CSS
【发布时间】:2014-11-20 22:01:03
【问题描述】:

我有下面的代码,我不明白哪里错了,IE8不喜欢它的什么地方

var flap = $("#flap");
var animationSupport = _g.animationDetection();

if(animationSupport) {
    flap.addClass("showAnimation");
}
else {
    flap.css('width', flap.width() + 'px').css('right', '-' + flap.width() + 'px');
    flap.animate({right: 0}, 1500);
}

当我这样做时,我有消息:

Object doesn't support property or method 'width'

不过,如果我执行以下操作,似乎没问题:

$("#flap").css("width", "300px").css("right", "-300px");

【问题讨论】:

  • IE 不理解你的 CSS,因为它是 IE。
  • 为什么要将襟翼宽度设置为他自己的宽度?这似乎是多余的......
  • 尝试改成fap.widthfap.css('width')
  • 该错误与 CSS 无关,这是一个 Javascript 错误。
  • 你在其他浏览器上试过了吗?

标签: jquery css internet-explorer-8


【解决方案1】:

我认为 .width() 可能不受 IE8 支持。试试这个:

flap.css('width', flap.css('width')).css('right', '-' + flap.css('width'));

【讨论】:

    【解决方案2】:

    记得在body和head中添加ie8支持代码

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-04-12
      • 1970-01-01
      • 2012-03-26
      • 2013-09-07
      • 2016-03-08
      • 1970-01-01
      • 2014-02-27
      • 1970-01-01
      相关资源
      最近更新 更多