<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>鼠标动版头</title>
<style>
.userDefinedArea {
width: 1920px;
margin: 0 auto
}
.user-yh-top {
width: 990px;
height: 565px;
position: relative;
margin: 0 auto;
margin: 0 auto;
}
.user-yh-top p {
position: absolute;
top: 0;
left: 50%;
}
.user-yh-top p.p1 {
margin-left: -960px;
width: 1920px;
height: 100%;
}
.user-yh-top p.p2 {
margin-left: -495px;
width: 990px;
height: 278px;
z-index: 9999;
}
.user-yh-top p.p3 {
margin-left: -495px;
width: 990px;
height: 284px;
bottom: 0;
top: auto;
}
.user-yh-top p.p4 {
margin-left: -524px;
width: 210px;
height: 344px;
top: 160px;
}
</style>
</head>
<body>
<div class="mc" style=" min-height:0px;">
<div class="j-module" module-function="autoCenter" module-param="{}">
<div class="userDefinedArea">
<div class="user-yh-top">
<p class="p1">![](http://upload-images.jianshu.io/upload_images/6449520-8e258859470e9c38.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)</p>
<p class="p2" >![](http://upload-images.jianshu.io/upload_images/6449520-66b7f9353125ab08.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)</p>
<p class="p3">![](http://upload-images.jianshu.io/upload_images/6449520-fdd5d7950d2b6f75.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)</p>
<p class="p4">![](http://upload-images.jianshu.io/upload_images/6449520-f0c9ed18dd839fcc.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)</p>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="http://t.moonbasa.com/Scripts/jquery-1.7.1.min.js?id=20141128"></script>
<script>
(function() {
$.fn.mouseMove = function() {
var container = $(this),
height = container.offset().top,
middle = $(window).width() / 2;
container.find('p.p2').each(function() {
var s = $(this);
s.attr('offset-left', s.css('left') || 0);
s.attr('offset-top', s.css('top') || 0);
s.attr('offset-speed-x', Math.random() * 0.08);
s.attr('offset-speed-y', Math.random() * 0.06);
});
$(document).mousemove(function(e) {
if ($(document).scrollTop() <= height) {
var myMouseX = e.pageX - middle,
myMouseY = e.pageY - height / 2;
container.find('p.p2').each(function() {
var s = $(this);
s.css('left', parseInt(s.attr('offset-left')) + myMouseX * parseFloat(s.attr('offset-speed-x')));
s.css('top', parseInt(s.attr('offset-top')) + myMouseY * parseFloat(s.attr('offset-speed-y')));
});
}
});
}
$('.user-yh-top').mouseMove();
})(jQuery);
</script>
</body>
</html>
版头跟随鼠标移动效果
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...