html - 背景图像 URL 的 CSS 转换失败

标签 html css firefox css-transitions

Fade Effect on Link Hover? 上找到以下示例

我做了这个:http://jsfiddle.net/felipelalli/ns9d1vug/

<div class="fade"/>

.fade {
-o-transition: 0.3s;
-moz-transition: 0.3s;
-khtml-transition: 0.3s;
-webkit-transition: 0.3s;
-ms-transition: 0.3s;
transition: 0.3s;

 width:128px;height:128px;
background:url('http://nuclearpixel.com/content/icons/2010-02-09_stellar_icons_from_space_from_2005/earth_128.png')
}

.fade:hover {
color: #b50000;
    width:128px;height:128px;
 background:url('http://upload.wikimedia.org/wikipedia/commons/b/b2/Crystal_128_babelfish.png')
}

为什么它在 Chrome 中运行良好但在 Firefox 中运行不正常?

最佳答案

它在 FF 中不起作用,因为 Firefox 不支持转换背景图像,只支持背景颜色。 如果要转换背景图像,请使用两个单独的 <div> :

.fade div {
-o-transition: 0.3s;
-moz-transition: 0.3s;
-khtml-transition: 0.3s;
-webkit-transition: 0.3s;
-ms-transition: 0.3s;
transition: 0.3s;
 width:128px;
  height:128px;
  position:absolute;
  top:0;
  left:0;
}
.fade{
  position:relative;
  width:128px;
  height:128px;
  }
.backone{
  z-index:1;
  background:url('http://nuclearpixel.com/content/icons/2010-02-09_stellar_icons_from_space_from_2005/earth_128.png');
  }
.backtwo{
background:url('http://upload.wikimedia.org/wikipedia/commons/b/b2/Crystal_128_babelfish.png');
  opacity:0;
z-index:5;
}
.fade:hover .backtwo{
opacity:1;
}
.fade:hover .backone{
opacity:0;
}
<div class="fade">
<div class="backone"></div>
<div class="backtwo"></div>
</div>

关于html - 背景图像 URL 的 CSS 转换失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28441749/

相关文章:

html - 我可以为表格、tr 或 td 使用最小高度吗?

javascript - 添加使段落折叠到段落的最后可见行的链接

javascript - 跨越两行时具有动态宽度的两个 div

javascript - 全屏 vlc,底部有控件

ubuntu - 有没有办法在 Puppeteer for Firefox 中使用代理?

Javascript 获取图像高度适用于所有浏览器,但 firefox ......请帮忙?

c# - CSS 不适用于电子邮件正文

html - Internet Explorer 9 和 10 中的 zIndex 问题

css - 是否可以使用 :hover on :first-child:after?

html - 背景位置在 Firefox/IE 中不起作用