On Hover(内容css标记)在Firefox和IE中不起作用 [英] On Hover(content css tag) is not working in Firefox and IE

查看:82
本文介绍了On Hover(内容css标记)在Firefox和IE中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在css中使用了内容标签用于悬停功能,因为我已经为图片标签提供了一个id。但是,on Hover在Firefox和IE中无效,而且它在chrome中工作正常。以下是此链接: thunderstorm999.byethost9.com



I have used content tag in css for the on hover function as I have given an id to the image tag.But, the on Hover is not working in Firefox and IE and it's working fine in chrome. Here is the link to this : thunderstorm999.byethost9.com

<ul class="navigation">
<li><a href="#"><img id="explore" src="images\explore.png"/></a></li>
<li><a href="#"><img id="material" src="images\material.png"/></a></li>
<li><a href="#"><img id="team" src="images\team.png"/></a></li>
<li><a href="#"><img id="contact" src="images\contact.png"/></a></li>
<li><a href="#"><img id="merchandise" src="images\merchandise.png"/></a></li>
</ul>







#explore:hover {
    content: url('images/explore-hover.png');
}
#material:hover {
    content: url('images/material-hover.png');
}
#team:hover {
    content: url('images/team-hover.png');
}
#contact:hover {
    content: url('images/contact-hover.png');
}
#merchandise:hover {
    content: url('images/merchandise-hover.png');
}

推荐答案

Firefox对非标准的uri过敏...'images \ ... png'不是一个,所以它拒绝显示...使用/而不是\在每个浏览器中获取正确的路径...

至于......内容属性存在一些问题...你面临的一个罕见的情况是IE(和Firefox)执行标准......

此属性可以使用 - 通过CSS标准 - 仅在上下文中使用:before和:after伪选择器...

其他浏览器允许在上下文中使用内容,但它不符合标准,并且可能在即将发布的版本中删除...

老实说,你不能改变一个src属性。使用CSS的img标签...

你可以做到orkaround使用background-image属性来执行此操作(您可以轻松找到Google提供的示例)...
Firefox has an allergy to non-standard uri... 'images\...png' is not one, so it refuses to display...Use / instead of \ to get the correct path in each browser...
As for both...There is some problem with the content attribute...You face one of the rare cases where IE (and Firefox too) enforces standard...
This attribute can be used - by CSS standard - only in the context of :before and :after pseudo-selectors...
Other browsers allow to use content out-of context, but it is not by the standard, and maybe removed in coming versions...
To be honest with you, you can not change the src attribute of an img tag using CSS...
You can do a workaround using background-image attribute to do so (there are samples you can find with Google easily)...


这篇关于On Hover(内容css标记)在Firefox和IE中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆