52,797
社区成员
发帖
与我相关
我的任务
分享
<style type="text/css">
.test{font-size:14px;width:50px;height:20px;line-height:20px;text-overflow:ellipsis; white-space:nowrap; overflow:hidden;}
#dvPop{position:absolute;width:100px;height:100px;overflow:auto;display:none;word-break:break-all;background:#eeeeee;border:solid 1px black;}
#dvPop .close{text-align:right;padding:3px 10px 3px 0px;font-size:12px;}
</style>
<div class="test" onmouseover="showPop(this)">1234567890abcdefghijklmn</div><br />
<div class="test" onmouseover="showPop(this)">444444fafeeeeeaaaaaa</div><br />
<div class="test" onmouseover="showPop(this)">xxxxxfafeeeeeaaaaaa</div><br />
<div class="test" onmouseover="showPop(this)">2333fbbaafefeafeeeeeaaaaaa</div><br />
<div id="dvPop">
<div class="close"><a href="#" onclick="this.parentNode.parentNode.style.display='none';return false;">关闭</a></div>
</div>
<script>
function $(Id){return document.getElementById(Id);}
function getAbsPos(o){
var p=new Object();
p.x=o.offsetLeft;
p.y=o.offsetTop;
while(o=o.offsetParent){
p.x+=o.offsetLeft;p.y+=o.offsetTop;
}
return p;
}
function showPop(o){
var p=getAbsPos(o),pop=$('dvPop');
pop.style.left=p.x+'px';
pop.style.top=p.y+o.offsetHeight+'px';
pop.innerHTML+=o.innerHTML;
pop.style.display='block';
}
</script>