CSS打造经典鼠标触发显示选项

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  2. <html xmlns="http://www.w3.org/1999/xhtml"> 
  3. <head> 
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
  5. <meta http-equiv="Content-Language" content="zh-CN" /> 
  6. <title>css打造鼠标触发效果</title> 
  7. <style type="text/css"> 
  8. <!-- 
  9. body { 
  10. margin: 0; 
  11. padding: 0; 
  12. color: #000; 
  13. font-size: 12px; 
  14. line-height: 160%; 
  15. text-align: left; 
  16. height: 100%; 
  17. font-family: '宋体',Tahoma ,arial,verdana,sans-serif,'Lucida Grande','Lucida Sans Unicode'; 
  18. *{ margin:0; padding:0;} 
  19. h2,h2 a:link,h2 a:hover,h2 a:visited{ 
  20. font-size: 14px; 
  21. text-decoration: none; 
  22. color: #000000; 
  23. .kw_from { 
  24. padding:20px 0 0 0px; 
  25. margin: auto; 
  26. height: 300px; 
  27. overflow: hidden; 
  28.  650px; 
  29. .kw_from .sbtn{ 
  30. float:left; 
  31. 80px; 
  32. padding: 16px 0 0 0; 
  33. .kw_from .searchMore{ 
  34. float:left; 
  35. 80px; 
  36. padding: 4px; 
  37. #searchNav { 
  38. 430px; 
  39. float: left; 
  40. #searchNav #conter1, #searchNav #conter3{ 
  41. float:left; 
  42. 250px; 
  43. #searchNav #conter2, #searchNav #conter4{ 
  44. float:left; 
  45. 180px; 
  46. #searchNav ul {  
  47. padding: 0; 
  48. margin: 0; 
  49. list-style: none; 
  50. #searchNav li { 
  51. float: left;  
  52. #searchNav li ul {  
  53. display: none;  
  54. top: 20px;  
  55. #searchNav li:hover ul, #searchNav li.over ul { 
  56. display: block; 
  57. float:left; 
  58. #searchNav ul li a{ 
  59. float:left; 
  60. display:block; 
  61. font-size:12px; 
  62. padding:3px; 
  63. text-decoration: none; 
  64. color: #777; 
  65. #searchNav ul li a:hover{ 
  66. background-color:#f4f4f4; 
  67. #searchNav #jobKw{ 
  68. 220px; 
  69. height:18px; 
  70. #searchNav #cityKw{ 
  71. 130px; 
  72. height:18px; 
  73. --> 
  74. </style> 
  75. <script type="text/javascript"> 
  76. <!--//--><![CDATA[//> 
  77. <!-- 
  78. startList = function() { 
  79. if (document.all&&document.getElementById) { 
  80. navRoot = document.getElementById("searchNav"); 
  81. for (i=0; i<navRoot.childNodes.length; i++) { 
  82. node = navRoot.childNodes[i]; 
  83. if (node.nodeName=="LI") { 
  84. node.onmouseover=function() { 
  85. this.className+=" over"; 
  86. } 
  87. node.onmouseout=function() { 
  88. this.className=this.className.replace(" over", ""); 
  89. } 
  90. } 
  91. } 
  92. } 
  93. } 
  94. window.onload=startList; 
  95. //--><!]]> 
  96. </script> 
  97. </head> 
  98. <body> 
  99. <div class="kw_from"> 
  100. <form action="/search.html" method="get" name="searchForm" id="searchForm" onsubmit="return check()"> 
  101.  
  102. <ul id="searchNav"> 
  103. <li id="conter1"><h2>找什么</h2> 
  104. <input id="jobKw" name="jobKw" type="text" /> 
  105. <ul id="conter3"> 
  106. <li><a href="#">会计</a> </li> 
  107. <li><a href="#">网页设计</a></li> 
  108. <li><a href="#">翻译</a></li> 
  109. <li><a href="#">家教</a></li>  
  110. <li><span class="moreCity"><a href="#">更多>> </a></span></li> 
  111. </ul> 
  112. </li> 
  113. <li id="conter2"><h2>在那里</h2> 
  114. <input id="cityKw" name="cityKw" type="text" /> 
  115. <ul id="conter4"> 
  116. <li><a href="#">北京</a> </li> 
  117. <li><a href="#">上海</a></li> 
  118. <li><a href="#">广州</a></li> 
  119. <li><a href="#">深圳</a></li> 
  120. <li><a href="#">南京</a></li> 
  121. <li><a href="#">天津</a></li> 
  122. <li><a href="#">杭州</a></li> 
  123. <li><a href="#">成都</a></li> 
  124. <li><a href="#">重庆</a></li> 
  125. <li><a href="#">武汉</a></li> 
  126. <li><a href="#">西安</a></li> 
  127. <li><a href="#">沈阳</a></li> 
  128. <li><span class="moreCity"><a href="#">更多城市>></a></span></li> 
  129. </ul> 
  130. </li> 
  131. </ul>  
  132. <div class="sbtn"> 
  133. <input name="submit" type="submit" class="btn4" style="margin:0px 15px 2px 0;" value="搜索工作" /> 
  134. </div> 
  135. <div class="searchMore"> 
  136. <a href="search_expert.html">高级搜索</a><br /><a href="search_sort.html">分类搜索</a> </div> 
  137. </form>  
  138. </div> 
  139. </body> 
  140. </html> 
原文地址:https://www.cnblogs.com/umgsai/p/3908166.html