{"id":470,"date":"2012-12-20T14:27:53","date_gmt":"2012-12-20T06:27:53","guid":{"rendered":"http:\/\/www.bluesdream.com\/blog\/?p=470"},"modified":"2012-12-20T14:56:30","modified_gmt":"2012-12-20T06:56:30","slug":"jquery-pictures-follow-the-mouse-floating","status":"publish","type":"post","link":"https:\/\/www.bluesdream.com\/blog\/jquery-pictures-follow-the-mouse-floating.html","title":{"rendered":"jQuery \u56fe\u7247\u8ddf\u968f\u9f20\u6807\u6d6e\u52a8"},"content":{"rendered":"<p>\u4e0d\u77e5\u4f60\u6709\u6ca1\u6ce8\u610f\u5230\u6211\u7684<a href=\"http:\/\/www.bluesdream.com\" target=\"_blank\">\u7f51\u7ad9\u9996\u9875<\/a>\uff0c\u4e0a\u9762\u6d6e\u52a8\u7740\u4e00\u5c42\u96ea\u82b1\u7684\u80cc\u666f\uff0c\u5e76\u4e14\u968f\u7740\u9f20\u6807\u7684\u79fb\u52a8\u4e5f\u5728\u79fb\u52a8\u7740\u3002<\/p>\n<p>\u672c\u6587\u4e3b\u8981\u8bb2\u8ff0\u4e86\u5982\u4f55\u5224\u65ad\u9f20\u6807\u7684\u4f4d\u7f6e\uff0c\u4ece\u800c\u5b9e\u73b0\u56fe\u7247\u8ddf\u968f\u9f20\u6807\u8fdb\u884c\u6d6e\u52a8\u3002\u4e3a\u4e86\u65b9\u4fbf\u67e5\u770b\u548c\u7406\u89e3\uff0c\u5728Demo\u7684\u5de6\u4e0b\u89d2\u628a\u5404\u4e2a\u53c2\u6570\u90fd\u6253\u5370\u4e86\u51fa\u6765\u3002<\/p>\n<p><strong>CSS CODE:<\/strong><\/p>\n<pre class=\"brush: css; title: ; notranslate\" title=\"\">\r\n&lt;style type=&quot;text\/css&quot;&gt;\r\n*{ margin:0; padding:0;}\r\nbody{ font-family:Arial; font-size:12px; background:url(bg.png) no-repeat; background-position:center center; background-attachment:fixed;}\r\ninput{ width:100px;}\r\nspan{ display:inline-block; width:120px;}\r\n#window{ color:white; position:absolute; bottom:10px; left:10px;}\r\n#coordinate{ color:white; position:absolute; bottom:35px; left:10px;}\r\n#location{ color:white; position:absolute; bottom:60px; left:10px;}\r\n#float_bg{ width:2496px; height:1060px; background:url(float_bg.png) no-repeat; position:fixed;}\r\n&lt;\/style&gt;\r\n<\/pre>\n<p><!--more--><\/p>\n<p><strong>HTML CODE:<\/strong><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;div id=&quot;float_bg&quot;&gt;&lt;\/div&gt;\r\n&lt;div id=&quot;window&quot;&gt;\r\n\t&lt;span id=&quot;window_x&quot;&gt;&lt;\/span&gt;\r\n\t&lt;span id=&quot;window_y&quot;&gt;&lt;\/span&gt;\r\n&lt;\/div&gt;\r\n&lt;div id=&quot;location&quot;&gt;\r\n\t&lt;span id=&quot;location_x&quot;&gt;&lt;\/span&gt;\r\n\t&lt;span id=&quot;location_y&quot;&gt;&lt;\/span&gt;\r\n&lt;\/div&gt;\r\n&lt;div id=&quot;coordinate&quot;&gt;\r\n\t&lt;span id=&quot;mouse_x&quot;&gt;&lt;\/span&gt;\r\n\t&lt;span id=&quot;mouse_y&quot;&gt;&lt;\/span&gt;\r\n&lt;\/div&gt;\r\n&lt;div id=&quot;test&quot;&gt;\r\n\t&lt;span id=&quot;test_a&quot;&gt;&lt;\/span&gt;\r\n\t&lt;span id=&quot;test_b&quot;&gt;&lt;\/span&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\n<p><strong>JAVASCRIPT CODE:<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n$(function(){\r\n\tvar my=0,mx=0;\r\n\t$(document).mousemove(function(e){\r\n\t\tvar x=e.pageX,y=e.pageY;\r\n\t\tif(mx==0) mx=x;\r\n\t\tif(my==0) my=y;\r\n\t\tml = x-mx;\r\n\t\tml = Math.ceil(ml\/150); \/\/\u5c06\u5c0f\u6570\u90e8\u5206\u4e00\u5f8b\u5411\u6574\u6570\u90e8\u5206\u8fdb\u4f4d\u3002\u5982\uff1aMath.ceil(10.0) \u8fd4\u56de10 \/ Math.ceil(10.1) \u8fd4\u56de11 \r\n\t\t$('#float_bg').css('left',ml);\r\n\t\tmt = y-my;\r\n\t\tmt = Math.ceil(mt\/100);\r\n\t\t$('#float_bg').css('top',mt);\r\n\r\n\t\tvar doc_width \t= $(document).width();\r\n\t\tvar doc_height\t= $(document).height();\r\n\t\tvar half_height\t= doc_width\/2;\r\n\t\tvar half_width\t= doc_height\/2;\r\n\t\t$(&quot;#window_x&quot;).text( &quot;Width: &quot; + doc_width );\r\n\t\t$(&quot;#window_y&quot;).text( &quot;Height: &quot; + doc_height);\r\n\t\t$(&quot;#mouse_x&quot;).text( &quot;Abscissa: &quot; + x );\r\n\t\t$(&quot;#mouse_y&quot;).text( &quot;Ordinate: &quot; + y );\r\n\t\tif( half_height &gt; x){ \/\/\u9f20\u6807\u7684x\u4f4d\u7f6e\r\n\t\t\t$(&quot;#location_x&quot;).text( &quot;Location: Left&quot; );\r\n\t\t}else{\r\n\t\t\t$(&quot;#location_x&quot;).text( &quot;Location: Right&quot; );\r\n\t\t}\r\n\t\tif( half_width &gt; y){ \/\/\u9f20\u6807\u7684y\u4f4d\u7f6e\r\n\t\t\t$(&quot;#location_y&quot;).text( &quot;Location: Up&quot; );\r\n\t\t}else{\r\n\t\t\t$(&quot;#location_y&quot;).text( &quot;Location: Down&quot; );\r\n\t\t}\r\n\t});\r\n});\r\n<\/pre>\n<p><a class=\"dlBtn\" title=\"Demo\" href=\"http:\/\/www.bluesdream.com\/case\/jquery\/jquery-pictures-follow-the-mouse-floating\/\" target=\"_blank\">Demo<\/a><a class=\"dlBtn\" title=\"Download\" href=\"http:\/\/www.bluesdream.com\/case\/jquery\/jquery-pictures-follow-the-mouse-floating\/jquery-pictures-follow-the-mouse-floating[bluesdream.com].rar\" target=\"_blank\">Download<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0d\u77e5\u4f60\u6709\u6ca1\u6ce8\u610f\u5230\u6211\u7684\u7f51\u7ad9\u9996\u9875\uff0c\u4e0a\u9762\u6d6e\u52a8\u7740\u4e00\u5c42\u96ea\u82b1\u7684\u80cc\u666f\uff0c\u5e76\u4e14\u968f\u7740\u9f20\u6807\u7684\u79fb\u52a8\u4e5f\u5728\u79fb\u52a8\u7740\u3002 \u672c\u6587\u4e3b\u8981\u8bb2\u8ff0\u4e86\u5982\u4f55\u5224\u65ad\u9f20\u6807\u7684\u4f4d\u7f6e\uff0c\u4ece\u800c\u5b9e\u73b0\u56fe\u7247\u8ddf\u968f\u9f20\u6807\u8fdb\u884c\u6d6e\u52a8\u3002\u4e3a\u4e86\u65b9\u4fbf\u67e5\u770b\u548c\u7406\u89e3\uff0c\u5728Demo\u7684\u5de6\u4e0b\u89d2\u628a\u5404\u4e2a\u53c2\u6570\u90fd\u6253\u5370\u4e86\u51fa\u6765\u3002 CSS CODE: &lt;style type=&quot;text\/css&quot;&gt; *{ margin:0; padding:0;} body{ font-family:Arial; font-size:12px; background:url(bg.png) no-repeat; background-position:center center; background-attachment:fixed;} input{ width:100px;} span{ display:inline-block; width:120px;} #window{ color:white; position:absolute; bottom:10px; left:10px;} #coordinate{ color:white; position:absolute; bottom:35px; left:10px;} #location{ color:white; position:absolute; bottom:60px; left:10px;} #float_bg{ width:2496px; height:1060px; background:url(float_bg.png) no-repeat; position:fixed;} &lt;\/style&gt;<\/p>\n","protected":false},"author":1,"featured_media":478,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[75],"tags":[71,29],"class_list":["post-470","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-front-end","tag-jquery","tag-original"],"_links":{"self":[{"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/posts\/470"}],"collection":[{"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/comments?post=470"}],"version-history":[{"count":0,"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/posts\/470\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/media\/478"}],"wp:attachment":[{"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/media?parent=470"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/categories?post=470"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/tags?post=470"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}