<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>jquery</title>
<script src="jquery.js" language="javascript" type="text/javascript"></script>
<script type="text/javascript">
var floatX,floatY,boxX,boxY,pageX,pageY;
var cX = document.documentElement.clientWidth;
var cY = document.documentElement.clientHeight;
$(document).ready(function(){
$('.ab').css({height:cY});
//从这里开始
$('#aa').hover(function(){
$(this).mousemove(function(event){
pageX = event.clientX + $(window).scrollLeft();
pageY = event.clientY + $(window).scrollTop();
boxX = $('#bb').outerWidth(true);
boxY = $('#bb').outerHeight(true);
if ((cX - event.clientX) < (boxX + 35)){
floatX = pageX - boxX - 15;
}else{
floatX = pageX + 15;
}
if ((cY - event.clientY) < (boxY + 10)){
floatY = pageY - boxY - 10;
}else{
floatY = pageY + 10;
}
$('#bb').css({top: floatY, left: floatX});
$('#bb').show();
});
},function(){
$('#bb').hide();
})
$(window).resize(function() {
cX = document.documentElement.clientWidth;
cY = document.documentElement.clientHeight;
});
})
</script>
<style type="text/css">
.ab{width:960px; float:left; height:80px; margin-bottom:100px;}
#aa{width:320px; height:30px; line-height:30px; float:left; background-color:#FCF;}
#bb{width:60px; height:60px; background-color:#CCC; line-height:30px; text-align:center; display:none; position:absolute;left:0;top:0;z-index:9999;}
</style>
</head>
<body>
<div style="margin-top:30px;"></div>
<div class="ab">
<div id="aa">111111111</div>
<div id="bb">222</div>
</div>
</body>
</html>
- 1
- 2
前往页