简体   繁体   English

WordPress网站的游标编码

[英]Cursor coding for wordpress site

I have the following code which I would like to implement in my Wordpress site, in order to have a customized mouse pointer. 我有以下代码,我希望在我的Wordpress网站中实现这些代码,以便获得自定义的鼠标指针。

where would I insert this code? 我在哪里插入此代码? Into the index.php file itself? 放入index.php文件本身? Or into a separate text file? 还是成一个单独的文本文件?

Thank you 谢谢

$(document).ready(function() { 

    $(document).mousemove(function(e) {

            //create img elements having pointer.png in their src 
            pointer = $('<img>').attr({'src':'pointer.png'});

            //and append them to document
            $(document.body).append(pointer); 

            //show them at mouse position & fade out slowly
            pointer.css({
                    'position':'absolute',
                    top: e.pageY +2 ,    //offsets
                    left: e.pageX +2   //offsets
                }).fadeOut(1500);   
});
});

There is a cursor rule in CSS. CSS中有一个cursor规则。 If you can modify the global CSS somewhere, just add cursor: url(/path/to/cursor.png); 如果可以在某处修改全局CSS,只需添加cursor: url(/path/to/cursor.png); to html or body . htmlbody

Normally you would put this <head><script>HERE</script></head> of the page you want it to be on. 通常,您要在要打开该页面的页面的<head><script>HERE</script></head>上放置。 Make sure you have imported jquery first though. 但是,请确保先导入了jquery。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM