内容网址不会在Firefox浏览器上显示图像

use*_*152 31 css firefox

.googlePic{
    content: url('../../img/googlePlusIcon.PNG');
    margin-top: -6.5%;
    padding-right: 53px;
    float:right;
    height: 19px;

}
Run Code Online (Sandbox Code Playgroud)

这是googlePic我的css文件中的一个示例.它的工作原理并打印出漂亮的google chromesafari.但是,它不起作用firefox.Nth打印出来.请帮忙 :)

Moh*_*eri 30

content物业与::before::after.

googlePic::before
{
 content: url('../../img/googlePlusIcon.PNG');
}
Run Code Online (Sandbox Code Playgroud)

阅读:http: //www.htmldog.com/reference/cssproperties/content/

content如果指定了!DOCTYPE,IE8仅支持该属性.

  • 在Firefox中,:之前没有为我工作,但是:之后,Ahetesum Ali报道了 (5认同)

0MB*_*BB0 18

我知道这可能是一个迟到的回应,但我遇到了同样的问题.

我查了一下,不知何故,网址不是一个有效的'内容'类型,甚至Chrome和Safari都是好人并且很好地展示它.

对我有用的是创建一个空的"内容"并使用背景来显示图像:它在Chrome,Firefox,Safari和IE8 + 9中运行良好

.googlePic:before {
    content: '';
    background: url('../../img/googlePlusIcon.PNG');
    margin-top: -6.5%;
    padding-right: 53px;
    float:right;
    height: 19px;
}
Run Code Online (Sandbox Code Playgroud)

编辑:忘了把:在classname之后


Dro*_*rap 15

你必须在风格上写两个css类

.googlePic
{  /*this for crome browser*/
    content: url('../../img/googlePlusIcon.PNG');
    margin-top: -6.5%;
    padding-right: 53px;
    float:right;
    height: 19px;

}

.googlePic: after
{  /*this for firefox browser*/
    content: url('../../img/googlePlusIcon.PNG');
    margin-top: -6.5%;
    padding-right: 53px;
    float:right;
    height: 19px;

}
Run Code Online (Sandbox Code Playgroud)

它的作品对我来说:)

  • 对我没意义.Firefox和IE - 没有反应 (4认同)
  • 在我的情况下:在伪元素获取Firefox后渲染,但不是:之前 (3认同)
  • 之后对我有用。请小心,删除 : after `.googlePic:after { /*this for firefox browser*/ content: url('../../img/googlePlusIcon.PNG'); 之间的空格 保证金顶部:-6.5%;右内边距:53px;浮动:右;高度:19 像素;}` (2认同)

Rom*_*ain 5

在所有 Web 浏览器中处理图像的最佳方法是将 background css 属性与 background-size 一起使用。但是,IE8 及更低版本将不支持它(占 2014 年观众的 2%)

.googlePic{
    background: url('../../img/googlePlusIcon.PNG') -6.5% 53px no-repeat;
    background-size: contain;
    float:right;
    height: 19px;
}
Run Code Online (Sandbox Code Playgroud)