【问题标题】:Sprites in Internet Explorer 6/7Internet Explorer 6/7 中的精灵
【发布时间】:2012-11-07 05:46:41
【问题描述】:

我似乎无法让我的精灵在 IE 7 及更低版本中正常工作。 (IE 9 工作正常) 下面是我的 CSS:

#info 
{
    width:100%;
    height:77px;
    background:url('../img/ck_sprite.png')no-repeat;
    background-position: 0px 0px;
    float:left;
    display:block;
    clear:both;
}
#info:hover
{ 
    width:100%;
    background:url('../img/ck_sprite.png')no-repeat;
    background-position: 0px -300px;
    cursor: default;
    float:left;
}

还有两个这样的类

我已尝试搜索该问题的解决方案,但解决方案不适用于我的问题。

编辑:对不起,我没有描述我的实际问题。图像在 IE 中根本不显示。

这是我的html代码:

              <div id="info">
              </div>        

                    <asp:Literal ID="litInfo" runat="server" />        



              <div id="bestilling">
              </div>          
                    <asp:Literal ID="litBestilling" runat="server" />          


              <div id="kontakt">

                    <asp:Literal ID="litKontakt" runat="server" />

如您所见,我用 C# 对网站进行了编码。文字放置在 div 之外,因为它们应该包含的唯一内容是图像。 (它们是头条新闻)

【问题讨论】:

  • 请向我们展示你的现场演示,这会更好......
  • 实际问题是什么。精灵不显示?显示在错误的位置?您应该在右括号和“不重复”声明之间留一个空格。
  • 啊老'不工作'错误..
  • 有什么问题?为什么你给我们展示了两种风格?正常 r 悬停状态是否发生错误?

标签: html css internet-explorer png sprite


【解决方案1】:

你没有提供你的 HTML,所以我假设你的 ID 应用到的标签不是锚标签?

IE6/7 仅支持 :hover 伪锚标签。

这应该可行:

a#info 
{
    width:100%;
    height:77px;
    background:url('../img/ck_sprite.png')no-repeat;
    background-position: 0px 0px;
    float:left;
    display:block;
    clear:both;
}
a#info:hover
{ 
    width:100%;
    background:url('../img/ck_sprite.png')no-repeat;
    background-position: 0px -300px;
    cursor: default;
    float:left;
}

...如果您的 HTML 是:

<p><a id="info" href="#">Hello World</a></p>

希望这有效吗?提供更多信息以获得更好的答案!

谢谢, 迈克尔。

【讨论】:

  • 感谢您的回答!我的 html 看起来像这样:
    它只是一个空的 DIV,文本是用 Literal 写出来的(该网站是用 C# 编码的)
  • 一点更新:我尝试应用 标签。但它没有工作。
  • 你能创建一个 JS fiddle 来弄乱吗?会容易得多。
猜你喜欢
  • 2010-10-09
  • 2011-07-15
  • 1970-01-01
  • 1970-01-01
  • 2011-08-15
  • 2010-12-23
  • 2011-11-06
  • 1970-01-01
相关资源
最近更新 更多