I know how to create custom cursors,
cursor: url('custom.svg'), default;
But how do you attach an icon to a existing pointer cursor?
I know how to create custom cursors,
cursor: url('custom.svg'), default;
But how do you attach an icon to a existing pointer cursor?
Share Improve this question edited Oct 27, 2017 at 10:24 semirturgay 4,2013 gold badges31 silver badges50 bronze badges asked Oct 27, 2017 at 10:13 user3607282user3607282 2,5556 gold badges37 silver badges65 bronze badges 1- 2 You can make your own icon and replace the default one. Have a look at jsfiddle/wNKcU/5 – Ali Zia Commented Oct 27, 2017 at 10:15
2 Answers
Reset to default 5you can try something like this :)
$(document).ready(function(){
$('html').mousemove(function(e){
var x = e.pageX - this.offsetLeft;
var y = e.pageY - this.offsetTop;
$('div.movablediv').css({'top': y,'left': x});
});
});
.movablediv {width:25px; height:25px; position:absolute; border:solid 1px #000}
<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="movablediv"></div>
If you don't want to use a custom image for the cursor you could use JavaScript. Here is an example with jQuery
$(function() {
$(document).mousemove(function(e) {
var iconPosition = {
top: e.pageY + 12,
left: e.pageX + 12
};
$('.cursor-icon').offset(iconPosition);
});
});
.cursor-icon {
z-index: 1000;
color: red;
font-size: 2em;
}
<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn./font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<span class="cursor-icon"><i class="fa fa-heart" aria-hidden="true"></i></span>
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742286325a4415387.html
评论列表(0条)