首页 新闻 搜索 专区 学院

li:hover怎么在IE6上出效果

0
悬赏园豆:10 [待解决问题]

:hover是在CSS中用来制作效果最常用到的一个伪类。比如:链接的鼠标悬停效果 a:hover 。

但用在比如li:hover 上再IE6下就没有效果,而Firefox下却解析正常。这样一来在Firefox下有漂亮的 hover 效果的标签用IE6来打开就会失去不少亮丽的风景了,然而 firefox 的用户有实在太少了,难道你小区旁边的网吧里都装了firefox 来作为默认的浏览器?

逍遥叹的主页 逍遥叹 | 初学一级 | 园豆:140
提问于:2010-12-07 20:59
< >
分享
所有回答(6)
0

a:hover li{border:1px solid red}之类的来处理吧,或者干脆就用js来实现吧...

三桂 | 园豆:3565 (老鸟四级) | 2010-12-07 22:21
谢了
支持(0) 反对(0) 逍遥叹 | 园豆:140 (初学一级) | 2010-12-08 09:01
0

IE6是不支持非A标签的:hover的,解决的办法如楼上所说,在li中添加a标签实现,另外一种就是js在焦点上控制样式,js的focus和blur。使用JQuery会简单很多,直接使用hover的方法即可。

Roy Zhang | 园豆:336 (菜鸟二级) | 2010-12-07 23:00
0

你可以试试在父元素上也加上个:hover伪类,再加上相同的属性

爱研究源码的javaer | 园豆:930 (小虾三级) | 2010-12-08 08:37
0

上面都回答过了,楼主该结贴了。

顾晓北 | 园豆:10819 (专家六级) | 2010-12-08 10:36
0

IE6 只支持 a元素的 hover  

xiaos | 园豆:434 (菜鸟二级) | 2010-12-10 16:45
0
因为:hover是在CSS是一个伪类,所以在ie6中你得给ie6单独写:

html:

<!--[if lte IE 6]>
<style type="text/css">
body { behavior:url("csshover3.htc路径"); }
</style>
<![endif]-->

 

 

csshover3.htc:

<public:attach event="ondocumentready" onevent="CSSHover()" />
<script>
/**
* Whatever:hover - V3.11
* http://www.xs4all.nl/~peterned/
*
* Copyright (c) 2009 Peter Nederlof
* Licensed under the LGPL license
* http://creativecommons.org/licenses/LGPL/2.1
*/
window.CSSHover=(function(){var m=/(^|\s)((([^a]([^ ]+)?)|(a([^#.][^ ]+)+)):(hover|active|focus))/i;var n=/(.*?)\:(hover|active|focus)/i;var o=/[^:]+:([a-z\-]+).*/i;var p=/(\.([a-z0-9_\-]+):[a-z]+)|(:[a-z]+)/gi;var q=/\.([a-z0-9_\-]*on(hover|active|focus))/i;var s=/msie (5|6|7)/i;var t=/backcompat/i;var u={index:0,list:['text-kashida','text-kashida-space','text-justify'],get:function(){return this.list[(this.index++)%this.list.length]}};var v=function(c){return c.replace(/-(.)/mg,function(a,b){return b.toUpperCase()})};var w={elements:[],callbacks:{},init:function(){if(!s.test(navigator.userAgent)&&!t.test(window.document.compatMode)){return}var a=window.document.styleSheets,l=a.length;for(var i=0;i<l;i++){this.parseStylesheet(a[i])}},parseStylesheet:function(a){if(a.imports){try{var b=a.imports;var l=b.length;for(var i=0;i<l;i++){this.parseStylesheet(a.imports[i])}}catch(securityException){}}try{var c=a.rules;var r=c.length;for(var j=0;j<r;j++){this.parseCSSRule(c[j],a)}}catch(someException){}},parseCSSRule:function(a,b){var c=a.selectorText;if(m.test(c)){var d=a.style.cssText;var e=n.exec(c)[1];var f=c.replace(o,'on$1');var g=c.replace(p,'.$2'+f);var h=q.exec(g)[1];var i=e+h;if(!this.callbacks[i]){var j=u.get();var k=v(j);b.addRule(e,j+':expression(CSSHover(this, "'+f+'", "'+h+'", "'+k+'"))');this.callbacks[i]=true}b.addRule(g,d)}},patch:function(a,b,c,d){try{var f=a.parentNode.currentStyle[d];a.style[d]=f}catch(e){a.runtimeStyle[d]=''}if(!a.csshover){a.csshover=[]}if(!a.csshover[c]){a.csshover[c]=true;var g=new CSSHoverElement(a,b,c);this.elements.push(g)}return b},unload:function(){try{var l=this.elements.length;for(var i=0;i<l;i++){this.elements[i].unload()}this.elements=[];this.callbacks={}}catch(e){}}};var x={onhover:{activator:'onmouseenter',deactivator:'onmouseleave'},onactive:{activator:'onmousedown',deactivator:'onmouseup'},onfocus:{activator:'onfocus',deactivator:'onblur'}};function CSSHoverElement(a,b,c){this.node=a;this.type=b;var d=new RegExp('(^|\\s)'+c+'(\\s|$)','g');this.activator=function(){a.className+=' '+c};this.deactivator=function(){a.className=a.className.replace(d,' ')};a.attachEvent(x[b].activator,this.activator);a.attachEvent(x[b].deactivator,this.deactivator)}CSSHoverElement.prototype={unload:function(){this.node.detachEvent(x[this.type].activator,this.activator);this.node.detachEvent(x[this.type].deactivator,this.deactivator);this.activator=null;this.deactivator=null;this.node=null;this.type=null}};window.attachEvent('onbeforeunload',function(){w.unload()});return function(a,b,c,d){if(a){return w.patch(a,b,c,d)}else{w.init()}}})();
</script>

百脑 | 园豆:205 (菜鸟二级) | 2011-12-05 17:47
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册