首页 > 代码库 > 鼠标控制图片反方向移动

鼠标控制图片反方向移动

css

.transformBox{
transform-style: preserve-3d;
-webkit-transition: all 0.5s ease-out;
-moz-transition: all 0.5s ease-out;
-o-transition: all 0.5s ease-out;
transition: all 0.5s ease-out;
}

 html

<div class="col-lg-4 transformBox">
<div style="transform: translateZ(100px);">
<img src="http://www.mamicode.com/images/bannerPic.png" />
</div>
</div>

js

$(‘.transformBox‘).mousemove(function (e) {
var xx = e.pageY/100;
var yy = e.pageX/100;
$(this).find(‘.aa‘).css({
"transform": "rotateX(" +xx+"deg) rotateY("+yy+"deg)"
//"transform":(+y)+"px"
});

});

 

鼠标控制图片反方向移动