相对鼠标位置定义div漂浮层



<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>
鼠标悬停事件
</title>
<style type="text/css">
.divstyle{
z-index:1;position:absolute;background-color:#999999;
}
#supplierDiv2 {
z-index:6;
position:relative;
text-align:right;
padding-left:5px;
padding-top:1px;
cursor: hand;
font-family: "Tahoma";
}
#supplierDiv3 {
z-index:7;
position:relative;
padding-top:10px;
padding-left:5px;
width:350px;
height:150px;
background-color:#ffffff;
padding: 5px;
text-align: left;
color: red;
font-size: 15px;
overflow-y:auto;
line-height:30px;
Filter: Alpha(Opacity=100, FinishOpacity=0, Style=1, StartX=0, StartY=0, FinishX=0, FinishY=100);
}
</style>
<script type="text/javascript">
function drawDiv(event,o)
{
document.getElementById("supplierDiv1").style.left=event.clientX;
document.getElementById("supplierDiv1").style.top=event.clientY;
document.getElementById("supplierDiv1").style.display="";
}
function closeDiv(){
document.getElementById("supplierDiv1").style.display="none";
}
</script>
</head>
<body>

<table border=1 width="1000px;">
<tr>
<td><a href="http://www.baidu.com" onmousemove="drawDiv(event,this)" >测试文字</a></td>
<td><a href="http://www.baidu.com" onmousemove="drawDiv(event,this)" >测试文字</a></td>
<td><a href="http://www.baidu.com" onmousemove="drawDiv(event,this)">测试文字</a></td>
</tr>
<tr>
<td><a href="http://www.baidu.com" onmousemove="drawDiv(event,this)" >测试文字</a></td>
<td><a href="http://www.baidu.com" onmousemove="drawDiv(event,this)" >测试文字</a></td>
<td><a href="http://www.baidu.com" onmousemove="drawDiv(event,this)">测试文字</a></td>
</tr>
<tr>
<td><a href="http://www.baidu.com" onmousemove="drawDiv(event,this)" >测试文字</a></td>
<td><a href="http://www.baidu.com" onmousemove="drawDiv(event,this)" >测试文字</a></td>
<td><a href="http://www.baidu.com" onmousemove="drawDiv(event,this)">测试文字</a></td>
</tr>
<tr>
<td><a href="http://www.baidu.com" onmousemove="drawDiv(event,this)" >测试文字</a></td>
<td><a href="http://www.baidu.com" onmousemove="drawDiv(event,this)" >测试文字</a></td>
<td><a href="http://www.baidu.com" onmousemove="drawDiv(event,this)">测试文字</a></td>
</tr>
<tr>
<td><a href="http://www.baidu.com" onmousemove="drawDiv(event,this)" >测试文字</a></td>
<td><a href="http://www.baidu.com" onmousemove="drawDiv(event,this)" >测试文字</a></td>
<td><a href="http://www.baidu.com" onmousemove="drawDiv(event,this)">测试文字</a></td>
</tr>
</table>
<div id="supplierDiv1" class="divstyle" style="display:none;">
<div id="supplierDiv2" onclick="closeDiv()">Close</div>
<div id="supplierDiv3" >
<a href="http://www.baidu.com" >一三九移动互联网信息服务(北京)有限公司</a><br>
<a href="http://www.baidu.com" >一三九移动互联网信息服务(北京)有限公司</a><br>
<a href="http://www.baidu.com" >一三九移动互联网信息服务(北京)有限公司</a><br>
<a href="http://www.baidu.com" >一三九移动互联网信息服务(北京)有限公司</a><br>
<a href="http://www.baidu.com" >一三九移动互联网信息服务(北京)有限公司</a><br><br>
</div>
</div>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值