<html><head><title>层与按钮对齐</title></head><body>
<div align=left><table border=1 width=600 height=50>
<tr align=center>
  <td>
    <input type=button value=ok onmouseover="cc(this)"
     onmouseout="document.all.pop.style.display='none'">
  </td><td>
    <input type=button value=ok onmouseover="cc(this)"
     onmouseout="document.all.pop.style.display='none'">
  </td><td>
    <input type=button value=ok onmouseover="cc(this)"
     onmouseout="document.all.pop.style.display='none'">
  </td></tr>
</table><div><div id=pop style="position:absolute;width:100;height:50;z-index:99;display:none">
<table border=0 bgcolor=#FF0000><tr><td>图层文字</td></tr></table></div><script language=javascript>
function cc(tt)
{
  var daps  = document.all.pop.style;
  var ttop  = tt.offsetTop;     //TT控件的定位点高
  var thei  = tt.clientHeight;  //TT控件本身的高
  var tleft = tt.offsetLeft;    //TT控件的定位点宽
  var ttyp  = tt.type;          //TT控件的类型
  while (tt = tt.offsetParent){ttop+=tt.offsetTop; tleft+=tt.offsetLeft;}
  daps.top  = (ttyp=="image")? ttop+thei : ttop+thei+6; //层的 Y 坐标
  daps.left = tleft + 1;  //层的 X 坐标
  daps.display = "";  //层显示
}
</script>
</body></html>

解决方案 »

  1.   

    <table width="50%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="50%"  style="position:relative">
    <input type="button"  value="Submit" onClick="Layer1.style.display='block'" onmouseout="Layer1.style.display='none'">
    <div id="Layer1" style="position:absolute; display:none; left:0 px; top:22px; width:162px; height:30px; z-index:1" onmouseover="Layer1.style.display='block'"  onmouseout="Layer1.style.display='none'">
      <table width="100%" border="0" cellspacing="1" cellpadding="0">
    <tr>
      
                <td bgcolor="#CCCCCC"><a href="#">shanghai</a></td>
    </tr>
    <tr>
      <td bgcolor="#CCCCCC">beijing</td>
    </tr>
      </table>
    </div>
    </td>
        <td>&nbsp;</td>
      </tr>
    </table>
      

  2.   

    meizz(梅花雨)真高
    向你学习