技术 - Web Design - 为所有的页面元素添加 :hover 属性

17
09 Feb.

为所有的页面元素添加 :hover 属性

最后更新: 2009/02/28  |  评论: 0  |  关键词: 页面  元素  属性  

FireFox 下,所有的页面元素都有 :hover 属性,当鼠标悬停时,可以变换样式,能给用户一个好的体验。但是 IE 下面,只有超级链接标签(A)才具备此属性,本文介绍的是通过 expression 设置,解决 IE 的这一问题。

  1. <style type="text/css" media="projection, screen">        
  2. .whatever {        
  3.     background#808080;        
  4.     padding10px;        
  5.     width:90%;        
  6.     margin:0 auto;        
  7.     color:#fff;        
  8. }        
  9. .whatever:hover, .whateverhover {        
  10.     background#eaeaea;        
  11.     color:#333;        
  12. }        
  13. </style>        
  14.        
  15. <!-- Additional IE/Win specific style sheet (Conditional Comments) -->        
  16. <!--[if lte IE 6]>        
  17. <style type="text/css" media="projection, screen">        
  18. .whatever {        
  19.     behavior: expression(        
  20.         this.onmouseover = new Function("this.className += ' whateverhover';"),        
  21.         this.onmouseout = new Function("this.className = this.className.replace(' whateverhover', '');"),        
  22.         this.style.behavior = null        
  23.     );        
  24. }        
  25. /*.whatever {       
  26.     background-color: expression(       
  27.         !this.js ? (this.js = 1,       
  28.             this.onmouseover = new Function("this.className += ' whateverhover';"),       
  29.             this.onmouseout = new Function("this.className = this.className.replace(' whateverhover', '');")       
  30.             ) : false);       
  31.     );       
  32. }*/       
  33. /*.whatever {       
  34.     background-color: expression(       
  35.         this.onmouseover = new Function("this.className += ' whateverhover';"),       
  36.         this.onmouseout = new Function("this.className = this.className.replace('whateverhover', '');")       
  37.     );       
  38. }*/       
  39. </style>        
  40. <![endif]--> 

 

· 本文由 木炭 发布在《激情燃烧的木炭》 上,原文地址为:http://www.woodcoal.cn/technology/web/2009217-15440-520.html(转载请保留本信息、全文内容和链接)

发表评论

已经有 0 位朋友发表了对《为所有的页面元素添加 :hover 属性》的看法
 
登录名:  密码:   登录  注册
评论: 
User:
Contact:
验证码:  
  [Ctrl+Enter]

关于本文