<td><div style="position:relative;left:100;top:50;">层</div></td>

解决方案 »

  1.   

    这样可以,但是有个问题,这个td内我放了一个图片,我想让这个层在mouse移动到此图片上时,才显示此层,这样的话,mouse移动上去时,这个图片会向下移动。也就是这个层把单元格撑大了怎么办?没办法只在图的上面显示吗?
      

  2.   

    你可以把层放在任意位置,当鼠标经过图片的时候,层显示的位置为与图片位置的相对距离,给你看个例子<?xml version="1.0" encoding="gb2312"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
              "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
    <head>
    <style>
     v\:* {behavior: url(#default#VML);}
    .spefont {font-size:32px;font-family:Webdings}
    </style>
    <script>
    document.onmousemove=function(){
    if(event.srcElement.id=="menu"){
    e=event.srcElement
    t=e.offsetTop; 
    l=e.offsetLeft;
    while(e=e.offsetParent){
    t+=e.offsetTop;
    l+=e.offsetLeft;}
    menubg.style.display=""
    menubg.style.left=l
    menubg.style.top=t
    menubg.style.width=event.srcElement.offsetWidth-1
    menubg.style.height=event.srcElement.offsetHeight-1
    }
    else{
    if(event.srcElement.id=="menuin"){
    e=event.srcElement.parentElement
    t=e.offsetTop; 
    l=e.offsetLeft;
    while(e=e.offsetParent){
    t+=e.offsetTop;
    l+=e.offsetLeft;}
    menubg.style.display=""
    menubg.style.left=l
    menubg.style.top=t
    menubg.style.width=event.srcElement.parentElement.offsetWidth-1
    menubg.style.height=event.srcElement.parentElement.offsetHeight-1
    }
    else
    menubg.style.display="none"
    }
    }
    document.onmouseout=function(){
    if(event.srcElement.id!="menu"||event.srcElement.id!="menuin")
    menubg.style.display="none"
    }
    </script>
    </head>
    <body leftmargin=0 topmargin=0 style="border:0px;overflow-x:hidden;overflow-y:scroll">
    <div   id=menubg style="position:absolute;top:-1;left:-1;z-index:-1;display:none;background:red">&nbsp;</div>
    <table width=770 cellpadding=0 cellspacing=0>
    <tr><td id=menu class=menu onclick="location='main.htm'">
    <a class=spefont>m</a><br>站点首页</td><td></td>
    <td id=menu class=menu onclick="location='script.htm'">
    <a class=spefont>`</a><br>脚本技术</td><td></td>
    <td id=menu class=menu onclick="location='relative.htm'">
    <a style="font-size:32px;font-family:Wingdings">z</a><br>相关资源</td><td></td>
    <td id=menu class=menu onclick="location='myopus.htm'">
    <a class=spefont>%</a><br>我的作品</td><td></td>
    <td id=menu class=menu onclick="location='contactme.htm'">
    <a style="font-size:32px;font-family:Wingdings">(</a><br>联系方式</td>
    <td width=300 align=right style="border-bottom:1 solid black">
    <span class=titlefont>Bencalie&nbsp;</span><br>基于脚本技术构建&nbsp;</td>
    </table>
    </center>
    </body>
    </html>
      

  3.   

    对不起,上面的代码漏了点东西<?xml version="1.0" encoding="gb2312"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
              "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
    <head>
    <style>
     v\:* {behavior: url(#default#VML);}
    .spefont {font-size:32px;font-family:Webdings}
    </style>
    <script>
    document.onmousemove=function(){
    if(event.srcElement.id=="menu"){
    e=event.srcElement
    t=e.offsetTop; 
    l=e.offsetLeft;
    while(e=e.offsetParent){
    t+=e.offsetTop;
    l+=e.offsetLeft;}
    menubg.style.display=""
    menubg.style.left=l
    menubg.style.top=t
    menubg.style.width=event.srcElement.offsetWidth-1
    menubg.style.height=event.srcElement.offsetHeight-1
    }
    else{
    if(event.srcElement.id=="menuin"){
    e=event.srcElement.parentElement
    t=e.offsetTop; 
    l=e.offsetLeft;
    while(e=e.offsetParent){
    t+=e.offsetTop;
    l+=e.offsetLeft;}
    menubg.style.display=""
    menubg.style.left=l
    menubg.style.top=t
    menubg.style.width=event.srcElement.parentElement.offsetWidth-1
    menubg.style.height=event.srcElement.parentElement.offsetHeight-1
    }
    else
    menubg.style.display="none"
    }
    }
    document.onmouseout=function(){
    if(event.srcElement.id!="menu"||event.srcElement.id!="menuin")
    menubg.style.display="none"
    }
    </script>
    </head>
    <body leftmargin=0 topmargin=0 style="border:0px;overflow-x:hidden;overflow-y:scroll">
    <div   id=menubg style="position:absolute;top:-1;left:-1;z-index:-1;display:none;background:red">&nbsp;</div>
    <table width=770 cellpadding=0 cellspacing=0>
    <tr><td id=menu class=menu onclick="location='main.htm'">
    <a id=menuin class=spefont>m</a><br>站点首页</td><td></td>
    <td id=menu class=menu onclick="location='script.htm'">
    <a id=menuin class=spefont>`</a><br>脚本技术</td><td></td>
    <td id=menu class=menu onclick="location='relative.htm'">
    <a id=menuin style="font-size:32px;font-family:Wingdings">z</a><br>相关资源</td><td></td>
    <td id=menu class=menu onclick="location='myopus.htm'">
    <a id=menuin class=spefont>%</a><br>我的作品</td><td></td>
    <td id=menu class=menu onclick="location='contactme.htm'">
    <a id=menuin style="font-size:32px;font-family:Wingdings">(</a><br>联系方式</td>
    <td width=300 align=right style="border-bottom:1 solid black">
    <span class=titlefont>Bencalie&nbsp;</span><br>基于脚本技术构建&nbsp;</td>
    </table>
    </center>
    </body>
    </html>
      

  4.   

    将Layer放在单元格内,再将单元格的格式设置如下:
    <td style="POSITION: relative">
       放layer
    </td>
    适当调整top,left的位置即可,这就是层的相对定位
      

  5.   

    bencalie(Bencalie) :请帮我把下面的相对层指示改一下,现在的问题是移动到图片时,图片会下移谢谢感激<html xmlns:YYC xmlns:v="urn:schemas-microsoft-com:vml">
      <head>
      <STYLE>
    v\:* { Behavior: url(#default#VML) }
    </STYLE>
      </head>
      <body>
    <br><br><br><br>
     <table>
     
     <tr>
     <td height=10>
     <v:shape id="msgbox"
      style='display:none;z-index:12;position:relative;left:0;top:0;"
      width:170px;height:50px' coordsize="21600,21600" adj="8607,,5400"
      path="m532,qx,532l,16745qy532,17277l2623,17277@1,21600,6515,17277r14501,qx21600,16745l21600,532qy21016,xe"
      fillcolor="white">
      <v:stroke joinstyle="miter"/>
      <v:shadow on="t" offset="3pt,3pt"/>
      <v:formulas>
       <v:f eqn="val 0"/>
       <v:f eqn="val #0"/>
      </v:formulas>
      <v:path textboxrect="145,145,21409,17106" />
      <v:textbox style="font-size:10pt;color:black;line-height:18px" inset="1,1,1,1">
       <span class=c>&nbsp;已经有<%//=seek_total%>用户浏览了此商品<br>&nbsp;已经有<%//=buy_total%>用户购买了此商品<br></span>
      </v:textbox>
      <v:handles>
       <v:h position="#0,bottomRight" xrange="0,21600" yrange="@0,2147483647"/>
      </v:handles>
     </v:shape>
     </td>
     </tr>
     
     <tr>
     <td>
     <img src="http://www.flashlong.com/flashlong-biglogo.gif" onmouseover="msgbox.style.display='block'" onmouseout="msgbox.style.display='none'" >
     </td>
     </tr>
     </table>
     </body>
     </html>
      

  6.   

    看这帖中我的回复:http://www.csdn.net/expert/topic/1002/1002736.xml?temp=.7846643用我的第二个方法就可以了。
      

  7.   

    哈哈~~ 楼上这位不会是 闪龙 的老大吧 ?!...  
    我先看看你的代码...
    ================================================================
    俺是"老"菜鸟一只, 请各位高手多指教!
    ------ 好好学习, 天天上网! --------
    →→→→→→→→→→→→→→→→→→→→↓
    ↑爽!.. google 终于又重获生机了! 庆贺!  ↓→→→→→→→→→
    ↑不过我的这个 Script 还可以用来找到其他的 google IP.  :)  ↓
    ↑ (包括新闻组)--http://www.boy.net.cn/home0/goldenlove    ↓
     ←←←←←←←←←←←←←←←←←←←←←←←←←←←←←↓
    多谢 CSDN 助手帮我自动加入签名. 
    www.chinaok.net
    ================================================================
      

  8.   

    晕..... 我把你的代码完整 copy 来看... 鼠标移到上面
    图片不会向下移啊 ?!.............一切正常.
    ================================================================
    俺是"老"菜鸟一只, 请各位高手多指教!
    ------ 好好学习, 天天上网! --------
    →→→→→→→→→→→→→→→→→→→→↓
    ↑爽!.. google 终于又重获生机了! 庆贺!  ↓→→→→→→→→→
    ↑不过我的这个 Script 还可以用来找到其他的 google IP.  :)  ↓
    ↑ (包括新闻组)--http://www.boy.net.cn/home0/goldenlove    ↓
     ←←←←←←←←←←←←←←←←←←←←←←←←←←←←←↓
    多谢 CSDN 助手帮我自动加入签名. 
    www.chinaok.net
    ================================================================
      

  9.   

    再晕....... 哈哈!! 楼上各位都是高手啊...无忧的 bencalie .. 钟钟 老大..楼主也厉害, 闪龙 的老大.呵呵.....
    ================================================================
    俺是"老"菜鸟一只, 请各位高手多指教!
    ------ 好好学习, 天天上网! --------
    →→→→→→→→→→→→→→→→→→→→↓
    ↑爽!.. google 终于又重获生机了! 庆贺!  ↓→→→→→→→→→
    ↑不过我的这个 Script 还可以用来找到其他的 google IP.  :)  ↓
    ↑ (包括新闻组)--http://www.boy.net.cn/home0/goldenlove    ↓
     ←←←←←←←←←←←←←←←←←←←←←←←←←←←←←↓
    多谢 CSDN 助手帮我自动加入签名. 
    www.chinaok.net
    ================================================================
      

  10.   

    to  bencalie(Bencalie), goldenlove(潇洒.net) 请用1024*768看一下,应该会发生位移。to sixi_fish(思溪的鱼) :你的方法可以。