Select列表下拉框之DIY

来源:互联网 发布:linux 查看文件夹大小 编辑:程序博客网 时间:2024/05/14 22:29

下拉框的样式是不能完全随心改变的,于是我就仿制一个,上边就是做出来的效果。先是一个input,右边的箭头是这个图片,下边的列表是一个table。代码如下:

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <html>
  3.         <head>
  4.                 <title>仿下拉框</title>
  5.                 <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
  6.                 <style type="text/css">
  7.                 .div_foot
  8.                 {
  9.                         scrollbar-3dlight-color:#E6E4E4;     /* 滚动条亮边框 */
  10.                         scrollbar-arrow-color:#E6E4E4;       /* 方向箭头     */
  11.                         scrollbar-track-color:#F6F5F4;       /* 拖动区域     */
  12.                         scrollbar-darkshadow-color:#D3D3D3;  /* 暗边框       */
  13.                         scrollbar-face-color:#E6E4E4;        /* 3D表面       */
  14.                         scrollbar-highlight-color:#E6E4E4;   /* 3D界面的亮边 */
  15.                         scrollbar-shadow-color:#E6E4E4;      /* 3D界面的暗边 */
  16.                         color:#444444;
  17.                         font-size:12px;
  18.                         border:1px solid #BCBCBC;
  19.                         border-top:1px solid #BCBCBC;
  20.                 }
  21.                  
  22.                 #foot td
  23.                 {
  24.                         color:#444444;
  25.                         font-size:12px;
  26.                         height:20px;
  27.                         padding-top:2px;
  28.                         padding-left:2px;
  29.                         background-color:#ffffff;
  30.                         cursor:hand;
  31.                 }
  32.                 .input_foot
  33.                 {
  34.                         border:1px 0 1px 1px solid #BCBCBC;
  35.                         border-right:0;
  36.                         color:#444444;
  37.                         font-size:12px;
  38.                         padding-top:2px;
  39.                         padding-left:2px;
  40.                         height:18px;
  41.                 }
  42.                 </style>
  43.                 <script>
  44.                 function showSelect(obj)
  45.                 {
  46.                         if (obj.style.display=='')
  47.                                 obj.style.display='none';
  48.                         else if (obj.style.display=='none')
  49.                                          obj.style.display='';
  50.                 }
  51.                 function goLink(url)
  52.                 {
  53.                         switch (url)
  54.                         {
  55.                                 case 0: window.open('http://www.baidu.com');break;
  56.                                 case 1: window.open('http://www.google.cn');break;
  57.                                 case 2: window.open('http://www.cctv.com');break;
  58.                                 case 3: window.open('http://www.kbs.co.kr');break;
  59.                                 case 4: window.open('http://www.sxtvs.com');break;
  60.                                 case 5: window.open('http://blog.leo-space.cn');break;
  61.                         }
  62.                         family.style.display'none';
  63.                 }
  64.                 function mover(obj)
  65.                 {
  66.                         obj.style.backgroundColor="#F3F3F3";
  67.                 }
  68.                 function mout(obj)
  69.                 {
  70.                         obj.style.backgroundColor="#FFFFFF";
  71.                 }
  72.                 </script>
  73.         </head>
  74.         <body>
  75.                 <div>
  76.                         <input type="text" style="width:99" class="input_foot" value="友情链接" readonly><img src="arrow0.gif" align="absmiddle" style="cursor:hand;" onclick="showSelect(family)">
  77.                 </div>
  78.                 <div id="family" class="div_foot" style="position:absolute;top:33; width:115px; height:82 ;display:none; overflow-y:scroll"
  79.                         onmouseout="this.style.display='none'" onmouseover="this.style.display=''">
  80.                         <table width="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#ffffff" height="100%">
  81.                                 <tr>
  82.                                         <td valign="top">
  83.                                                 <table width="100%" cellpadding="0" cellspacing="0" border="0" id="foot">
  84.                                                         <tr>
  85.                                                                 <td onmouseover="mover(this)" onmouseout="mout(this)" onclick="goLink(0)">百度</td>
  86.                                                         </tr>
  87.                                                         <tr>
  88.                                                                 <td onmouseover="mover(this)" onmouseout="mout(this)" onclick="goLink(1)">Google中国</td>
  89.                                                         </tr>
  90.                                                         <tr>
  91.                                                                 <td onmouseover="mover(this)" onmouseout="mout(this)" onclick="goLink(2)">央视国际</td>
  92.                                                         </tr>
  93.                                                         <tr>
  94.                                                                 <td onmouseover="mover(this)" onmouseout="mout(this)" onclick="goLink(3)">韩国KBS</td>
  95.                                                         </tr>
  96.                                                         <tr>
  97.                                                                 <td onmouseover="mover(this)" onmouseout="mout(this)" onclick="goLink(4)">陕西电视台</td>
  98.                                                         </tr>
  99.                                                         <tr>
  100.                                                                 <td onmouseover="mover(this)" onmouseout="mout(this)" onclick="goLink(5)">新浪漓鸥空间</td>
  101.                                                         </tr>
  102.                                                 </table>
  103.                                         </td>
  104.                                 </tr>
  105.                         </table>
  106.                 </div>
  107.         </body>
  108. </html>
原创粉丝点击