好處是可以簡化開發,讓設計師可以自己去控制想要的樣式。
壞處是執行大量的 expression 會讓 IE6 很吃重。
ie_hover.htc 中的程式碼:
this.onmouseover=function(){
if(!this.className.match(/(^|\s)hover(\s|$)/)){
this.className=(this.className+' hover')
.replace(/\s{2,}/g,' ')
.replace(/^\s+|\s+$/g, '');
}
}
this.onmouseout=function(){
this.className=this.className
.replace(/(^|\s)hover(\s|$)/,' ')
.replace(/\s{2,}/g,' ')
.replace(/^\s+|\s+$/g, '');
}
this.style.behavior=null;
ie_hover.html 中的 CSS:
p{
padding-left:30px;
behavior: url(ie_hover.htc);
}
p:hover,
p.hover{
padding-left:0;
}
展示頁面(Demo Page)
0 回應:
張貼留言