1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
| <!DOCTYPE HTML>
<html>
<head>
<title>jq实现鼠标不同方位移入动态监测源码免费下载</title>
<meta charset="utf-8">
<meta name="Author" content="jq实现鼠标不同方位移入动态监测源码免费下载">
<style type='text/css'>
*{ margin:0; padding:0;}
#wrap{
width:1200px;
height:360px;
margin:100px auto;
}
#wrap ul li{
width:230px;
height:360px;
float:left;
list-style:none;
margin-right:12px;
position:relative;
overflow:hidden;
}
#wrap ul li img{
display:block;
}
#wrap ul li .cover{
width:230px;
height:360px;
position:absolute;
top:0px;
left:230px;
background:url(img/new-bg.png);
}
#wrap ul li .cover p{
font-size:14px;
font-family:'Microsoft yahei';
color:#fff;
text-align:center;
}
#wrap ul li .cover p.p1{
padding-top:160px;
}
</style>
</head>
<body>
<div id="wrap">
<ul>
<li>
<img src="img/1.jpg" alt="" />
<div class='cover'>
<p class='p1'>春夏新品 上新无限</p>
<p>点击进入</p>
</div>
</li>
<li>
<img src="img/2.jpg" alt="" />
<div class='cover'>
<p class='p1'>夏装新品发布 8折起</p>
<p>点击进入</p>
</div>
</li>
<li>
<img src="img/3.jpg" alt="" />
<div class='cover'>
<p class='p1'>春装特惠 买二送一</p>
<p>点击进入</p>
</div>
</li>
<li>
<img src="img/4.jpg" alt="" />
<div class='cover'>
<p class='p1'>春夏新品 低至158</p>
<p>点击进入</p>
</div>
</li>
<li style="margin-right:0px;">
<img src="img/5.jpg" alt="" />
<div class='cover'>
<p class='p1'>美洲野牛旗舰店</p>
<p>商务休闲新境界</p>
</div>
</li>
</ul>
</div>
<script type="text/javascript" src="js/jquery-1.12.1.min.js"></script>
<script type="text/javascript">
(function(){
var $li = $('#wrap ul li');
$li.hover(function(ev){
move.call(this , ev , true);
},function(ev){
move.call(this , ev , false);
});
function move( ev , bool ){
var top = $(this).offset().top;
var bottom = top + $(this).height();
var left = $(this).offset().left;
var right = left + $(this).width();
var x = ev.pageX,
y = ev.pageY;
var sT = Math.abs(y - top),
sB = Math.abs(y - bottom),
sL = Math.abs(x - left),
sR = Math.abs(x - right);
var a = Math.min( sT , sB , sL , sR );
switch ( a )
{
case sT:
if ( bool )
{
$(this).find('.cover').css({
left : 0,
top : '-360px'
}).stop().animate({
top : 0
},200);
}
else
{
$(this).find('.cover').stop().animate({
top : '-360px'
},200);
}
break;
case sB:
if ( bool )
{
$(this).find('.cover').css({
left : 0,
top : '360px'
}).stop().animate({
top : 0
},200);
}
else
{
$(this).find('.cover').stop().animate({
top : '360px'
},200);
}
break;
case sL:
if ( bool )
{
$(this).find('.cover').css({
top : 0,
left : '-230px'
}).stop().animate({
left : 0
},200);
}
else
{
$(this).find('.cover').stop().animate({
left : '-230px'
},200);
}
break;
case sR:
if ( bool )
{
$(this).find('.cover').css({
top : 0,
left : '230px'
}).stop().animate({
left : 0
},200);
}
else
{
$(this).find('.cover').stop().animate({
left : '230px'
},200);
}
break;
}
//console.log( '距离顶部:'+sT+' 距离底部:'+sB+' 距离左边:'+sL+' 距离右边:'+sR )
};
})();
</script>
</body>
</html> |
共 0 条评论关于"jq实现鼠标不同方位移入动态监测源码免费下载"
最新评论