【问题标题】:IE8 - button background Image not showing?IE8 - 按钮背景图片不显示?
【发布时间】:2012-01-16 15:04:12
【问题描述】:

我有一个具有以下 CSS 的提交按钮:

  .button{
    border:1px solid #015691;
    background-image:url('http://boundsblazer.com/pkg/pics/
         buttons/small-button.png');
    color:#ffffff;
    height:18px;
    font-size:8pt;
    font-family:sans-serif, verdana;
    cursor:pointer;
    line-height:14px;
    margin-bottom:-5px;
    border-bottom-color:#222222;

    -webkit-border-radius: 3px 3px 3px 3px;
    -moz-border-radius: 3px 3px 3px 3px;
    border-radius: 3px 3px 3px 3px;
    behavior: url("http://boundsblazer.com/pkg/plugins/PIE.htc");
  }

还有我的 JQuery...

$(".button").mousedown(function(){
    $(this).css('border-bottom-width', '0px');
    $(this).css('background-image', 'url(\'http://boundsblazer.com/pkg/pics/buttons/small-button-pressed.png\')');

    $(this).mouseout(function(){
          $(this).css('border-bottom-width', '1px');
          $(this).css('background-image', 'url(\'http://boundsblazer.com/pkg/pics/buttons/small-button.png\')');
    });
    $(this).mouseup(function(){
          $(this).css('border-bottom-width', '1px');
          $(this).css('background-image', 'url(\'http://boundsblazer.com/pkg/pics/buttons/small-button.png\')');
    });
});

奇怪的是,这在 IE7 或 IE9 中没有问题,只有 IE8。发生的情况是按钮的图像没有显示。它适用于 Safari、Chrome、Firefox、Opera、IE7 和 IE9,但不适用于 IE8。如果你想看到它,它的http://boundsblazer.com。请帮忙!

顺便说一句,“边框解决方案”不起作用,正如您所见,我在 CSS 中声明了边框。

问题已解决:

behavior 标签在 IE8 中不起作用,因此如果您希望 PIE CSS3 用于 IE8 中的圆角边框,那就不行了。另外,添加:

background:transparent url()

并摆脱:

background-image:url()

工作。

【问题讨论】:

  • url() 的参数不需要单引号。你试过$(this).css("background-image", "url(http://boundsblazer.com/pkg/pics/buttons/small-button-pressed.png)");吗?
  • 这并没有改变任何东西...... :(
  • 会不会是.button中的行为把背景变成了IE8不理解的东西?
  • 也许,我先剪一下。
  • 是的,这就是问题所在!但是我将如何实现圆形边框? D:

标签: javascript jquery html css internet-explorer-8


【解决方案1】:

简单,改变:

background-image:url('http://boundsblazer.com/pkg/pics/buttons/small-button.png');

到:

background:transparent url('http://boundsblazer.com/pkg/pics/buttons/small-button.png');

您还需要更改 jquery。

Load this in IE8

阿尔

【讨论】:

  • 我不确定我是否记录了确切的问题,但在可能的情况下,当您第一次声明背景时,请始终使用background:,然后您可以在以后的 css 中更具体并使用background-image:
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-01-29
  • 1970-01-01
  • 1970-01-01
  • 2013-03-05
  • 2020-09-11
相关资源
最近更新 更多