IE 6マウスサスペンションBug

11617 ワード

マウスがテキストリンクの上に配置されると、文字や文字の背景が他の色やスタイルに変更される効果が最もよく見られるマウスのサスペンション効果です.CSSでは,この効果は擬似要素:hoverで実現されるが,文字リンクではhoverがアンカー要素适用于实际上,CSS 2可以用于任意html要素的hover拟似要素.たとえば、1 P :hover{ background-color : #F7F7F7 ;} 这个CSS文可以改变在1个段落的文字上放置口罩的文字背景色.在Web设计中,hover拟似要素的一般使用例强调在名单中选择的行为,通常改变了背景色,可以防止看到行为.但是,很遗憾,在IE 6以及以下的版本中,安卡要素除了html要素的影响效果没有支持。当然,这个问题也没有解决方案.为了实现这样的效果Whatever:hover 3.11を使用することができる.
まず、Whatever:hover 3.11ファイルをダウンロードします.そしてあなたのCSSでbody要素に適用します1 body {behavior:  url ( "csshover3.htc" );}
コード、urlアドレスを変更してこのファイルを参照すると、IE 6は他の要素のマウスのサスペンション効果をサポートすることができます.具体的には、IE 6のマウスサスペンション効果をどのように実現するかについては、この編の記事を参照してください.P :hover{ background-color : #F7F7F7 ;}
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>

  body {behavior:  url ( "csshover3.htc" );}