純css下拉式功能表

來源:互聯網
上載者:User

參考自http://www.17css.com/a-detailed-explanation-of-the-css-drop-down-menu/

 

Code:
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  
  2. <html>  
  3.  <head>  
  4.   <title> 純CSS下拉式功能表 </title>  
  5.   <meta name="Generator" content="EditPlus">  
  6.   <meta name="Author" content="">  
  7.   <meta name="Keywords" content="">  
  8.   <meta name="Description" content="">  
  9.  </head>  
  10. <style type="text/css">  
  11.     *{margin:0;padding:0;}  
  12.       
  13.     body  
  14.     {  
  15.         background:pink;  
  16.     }  
  17.   
  18.     .menu  
  19.     {  
  20.         margin:20px auto 20px;  
  21.         width:400px;  
  22.         border:5px solid black;  
  23.         background-color:gray;  
  24.   
  25.     }  
  26.     .menu ul li  
  27.     {  
  28.         list-style-type:none;  
  29.         float:left;  
  30.     }  
  31.     .menu ul li a  
  32.     {  
  33.         text-align:center;  
  34.         color:pink;  
  35.         display:block;  
  36.         text-decoration:none;  
  37.         width:100px;  
  38.         background-color:gray;  
  39.         font-size:20px  
  40.     }  
  41.     .menu ul li ul{display:none;}  
  42.       
  43.     .menu ul li:hover a  
  44.     {  
  45.         color:white;  
  46.         background-color:#696969;  
  47.     }  
  48.     .menu ul li:hover ul  
  49.     {  
  50.         display:block;  
  51.         position:absolute;  
  52.         width:100px;  
  53.     }  
  54.     .menu ul li:hover ul li a  
  55.     {  
  56.         display:block;  
  57.         background-color:gray;  
  58.         color:snowy;  
  59.     }  
  60.     .menu ul li:hover ul li a:hover  
  61.     {  
  62.         background-color:#696969;  
  63.         color:white;  
  64.     }  
  65. </style>  
  66.  <body>  
  67.   <div class="menu">  
  68.   <ul>  
  69.     <li><a href="#">ONE</a>  
  70.         <ul>  
  71.             <li><a href="#">one</a></li>  
  72.             <li><a href="#">two</a></li>  
  73.             <li><a href="#">three</a></li>  
  74.         </ul>  
  75.     </li>  
  76.     <li><a href="#">TWO</a>  
  77.             <ul>  
  78.             <li><a href="#">one</a></li>  
  79.             <li><a href="#">two</a></li>  
  80.             <li><a href="#">three</a></li>  
  81.         </ul>  
  82.     </li>  
  83.     <li><a href="#">THREE</a>  
  84.             <ul>  
  85.             <li><a href="#">one</a></li>  
  86.             <li><a href="#">two</a></li>  
  87.             <li><a href="#">three</a></li>  
  88.         </ul>  
  89.     </li>  
  90.     <li><a href="#">FOUR</a>  
  91.             <ul>  
  92.             <li><a href="#">one</a></li>  
  93.             <li><a href="#">two</a></li>  
  94.             <li><a href="#">three</a></li>  
  95.         </ul>  
  96.     </li>  
  97.   </ul>  
  98.   </div>  
  99.  <p style="text-align:center;padding:20px;"> <a href='http://www.17css.com/a-detailed-explanation-of-the-css-drop-down-menu/' title="參考自http://www.17css.com/a-detailed-explanation-of-the-css-drop-down-menu/">詳情點擊這裡</a></p>  
  100. <p style='position:fixed;top:96%;left:42%'>http://www.17css.com/</p>  
  101.   
  102.   
  103.  </body>  
  104. </html>  

 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.