Der*_*rek 0 html javascript css jquery css3
因此,当您在元素上使用鼠标时,我一直在寻找复制Land Rover网站并添加动画鼠标效果的方法.例如,请查看此页面:http://www.landroverusa.com/index.html,看看在"滑块"区域中移动鼠标时会发生什么.它看起来像它的CSS来处理鼠标图像,但我如何复制像上面的网站一样标题鼠标指针图像的动画?
到目前为止,这是我所拥有的这个链接:
<style>
* {
cursor: none;
}
figure#mouse-pointer {
background-image: url('http://cdns2.freepik.com/image/th/318-70851.png');
background-size:44px 44px;
width: 44px;
height: 44px;
position: absolute;
margin-left: -8px;
display: block;
}
</style>
<figure id="mouse-pointer"></figure>
<script>
$(function (){
// Based on example found here: http://creative-punch.net/2014/01/custom-cursors-css-jquery/
$(window).mousemove(function(event) {
$('#mouse-pointer').css({
'top' : event.pageY + 'px',
'left' : event.pageX + 'px'
});
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
这是一个小提琴:https://jsfiddle.net/yqd5xzvc/1/
这是对这一个...
$(function() {
var windowMid = $(window).width() / 2;
$(window).mousemove(function(event) {
$('#mouse-pointer').css({
'top': event.pageY + 'px',
'left': event.pageX + 'px'
});
if (event.pageX > windowMid) {
$('#mouse-pointer').css('transform', 'rotate(180deg)');
} else {
$('#mouse-pointer').css('transform', 'rotate(0deg)');
}
});
});Run Code Online (Sandbox Code Playgroud)
* {
cursor: none;
}
figure#mouse-pointer {
background-image: url('http://cdns2.freepik.com/image/th/318-70851.png');
background-size: 44px 44px;
width: 44px;
height: 44px;
position: absolute;
margin-left: -8px;
display: block;
transition: 0.5s transform;
}
.rotate {
transform: rotate(180deg);
}Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<figure id="mouse-pointer"></figure>Run Code Online (Sandbox Code Playgroud)