【问题标题】:Firefox does not show the logo while Chrome doesFirefox 不显示徽标,而 Chrome 显示
【发布时间】:2014-06-25 20:07:59
【问题描述】:

我有以下css:

 #logo{
    content: url(../images/logo.svg) 0 0 no-repeat;
    background-color: black;
    margin-top: 30px;
    height: 20px;
    width: 100px;
  }
  #logo-container{
    background-color: black;
    margin-top: 0px;
    height: 65px;
    width: 100px;
  }

使用该 html:

<div class="col-md-1 col-md-offset-1 col-xs-3 ">
                <div id="logo-container"><a id="logo" href="#firstpage" data-target="start" title="EPIC Companies"></a></div>  
            </div>

Chrome 正确显示徽标,而 Firefox 显示黑色矩形(仅容器)。我做错了什么?

【问题讨论】:

标签: html css google-chrome firefox


【解决方案1】:

Firefox 对content 属性的支持有限,具体来说,它不能用于图像。

您可能必须使用&lt;img&gt; 标签。

编辑:根据链接的重复问题,如果您将它与 :before:after 伪属性一起使用,它看起来实际上可以在 Firefox 中工作。

【讨论】:

【解决方案2】:

content 只能用于:after:before 等伪元素中。

所以这样使用:

#logo:after {
    content: url(../images/logo.svg) 0 0 no-repeat;
    background-color: black;
    margin-top: 30px;
    height: 20px;
    width: 100px;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-09-26
    • 2021-10-11
    • 2013-01-21
    • 1970-01-01
    • 1970-01-01
    • 2015-01-11
    • 1970-01-01
    相关资源
    最近更新 更多