[英]Change Mouse cursor according to X/Y position
Is there a simple cross-browser css3 solution to altering the mouse cursor to a clear right/ left graphic according to the mouse position within a div? 是否有一个简单的跨浏览器CSS3解决方案,可根据div中的鼠标位置将鼠标光标更改为清晰的左右图形? Or is this a JQuery plugin job? 还是这是一个JQuery插件工作?
As in the mouse reaction in the carousel area in this http://themeforest.net/item/flamingo-agency-freelance-portfolio-theme/full_screen_preview/6077145 就像此http://themeforest.net/item/flamingo-agency-freelance-portfolio-theme/full_screen_preview/6077145中轮播区域中的鼠标反应一样
You can use the :hover selector with the cursor property to do this. 您可以将:hover选择器与cursor属性一起使用。 Make two fixed, transparent elements for each half of the page to use with :hover, and specify a custom cursor image by assigning cursor
a URL. 为页面的每半部分制作两个固定的透明元素,以与:hover一起使用,并通过为cursor
分配一个URL来指定自定义游标图像。 No JS required... 不需要JS ...
With JS programatically make a div follow the hidden cursor. 使用JS,可以使div跟随隐藏的光标。 See example: 参见示例:
<div class="main_area">
...
...
...
</div>
<!--
// The html:
-->
<div id="custom_cursor">HELLO</div>
<!--
// The script uses jQuery
-->
<script type="text/javascript">
$(document).ready(function(){
var $area = $('.main_area').css({
'cursor':'none'
}),
$myCursor = $('.custom_cursor').css({
'position': 'fixed',
'z-index': '999'
})
if ($myCursor.lenght){
$area
.on('mouseout.customCursor', function(){
$myCursor.hide()
})
.on('mousemove.customCursor', function(event){
$myCursor.show().css({
'left': event.clientX - 20,
'top': event.clientY + 7
})
})
}
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.