【问题标题】:use a sprite png in li-class and display in div在 li-class 中使用 sprite png 并在 div 中显示
【发布时间】:2012-12-04 02:03:50
【问题描述】:

li 类中的 div 中显示精灵时遇到了一些问题。

所以结构是:

<li id="aa">
    <div><a href="#">one</a></div>
</li>

还有 CSS:

li{
        width: 120px;
    height: 18px;
    margin-top: 5px;
}
li div{
        width: 20px;
    height: 10px;
    background-image:url(../images/sprite.png);
    background-repeat: no-repeat;
    margin-left: 0px;
    font-weight:bolder;
    border: 1px solid #fff;
}

当我使用它时,我什至可以在 div 之外看到精灵。所以我尝试将此添加到li:

背景图片:无;

这使得 div 中的图像也不可见。

因此,如果有人知道这一点,我将不胜感激。

【问题讨论】:

标签: css html styles html-lists


【解决方案1】:

背景图片后似乎缺少;,请参见下文

background-image:url(../images/sprite.png);

【讨论】:

  • @bonny 我已经用你上面的代码做了一个小提琴,但我可以看到图像jsfiddle.net/jcrTE 图像路径可能是错误的吗?还是图片的位置?
  • 您好,感谢您回答这个问题。这是两者的结合。失踪 ;加上缺少背景图片:无。
猜你喜欢
  • 1970-01-01
  • 2021-07-17
  • 2017-10-01
  • 1970-01-01
  • 2023-03-10
  • 1970-01-01
  • 2017-02-28
  • 1970-01-01
  • 2014-04-09
相关资源
最近更新 更多