起先是闲逛到anotherhome,发现博客里有个浮动的芽衣子萌萌哒,遂想自己也在博客里养点什么。于是借(chao)鉴(xi)了他的代码,自己找了张萌萌的狮子saber扣了图,做了自己博客的这个小(rou)宠(bian)物(qi)。
教程anotherhome里有,我再贴一下。下载下面的脚本和素材文件,下载解压后放在网站相应目录下
素材文件
这个脚本需要jQuery库,必须先加载jQuery库(有可能是原来已经加载了,这样就不用设置),您可能需要修改spig.js里面的一些东西,比如里面的一些域名网址提示等。然后把下面代码加到footer.php底部文件body里。
<!--.浮动小人--> <script type="text/javascript"> <?php if(is_home()) echo 'var isindex=true;var title="";';else echo 'var isindex=false;var title="', get_the_title(),'";'; ?> <?php if((($display_name = wp_get_current_user()->display_name) != null)) echo 'var visitor="',$display_name,'";'; else if(isset($_COOKIE['comment_author_'.COOKIEHASH])) echo 'var visitor="',$_COOKIE['comment_author_'.COOKIEHASH],'";';else echo 'var visitor="游客";';echo "\n"; ?> </script> <script type="text/javascript" src="http://myhloli.com/spig.js"></script> <style> .spig {display:block;width:130px;height:170px;position:absolute;bottom: 300px;left:160px;z-index:9999;} #message{color :#191919;border: 1px solid #c4c4c4;background:#ddd;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;min-height:1em;padding:5px;top:-45px;position:absolute;text-align:center;width:auto !important;z-index:10000;-moz-box-shadow:0 0 15px #eeeeee;-webkit-box-shadow:0 0 15px #eeeeee;border-color:#eeeeee;box-shadow:0 0 15px #eeeeee;outline:none;} .mumu{width:130px;height:170px;cursor: move;background:url(https://myhloli.com/wp-content/themes/loveloli/img/spig.png) no-repeat;} </style> <div id="spig" class="spig"> <div id="message">加载中……</div> <div id="mumu" class="mumu"></div> </div> <!--.end浮动小人-->
其中这两行代码换成你的路径
<script type="text/javascript" src="http://myhloli.com/spig.js"></script>
.mumu{width:130px;height:170px;cursor: move;background:url(https://myhloli.com/wp-content/themes/loveloli/img/spig.png) no-repeat;}
弄完之后再看下你的博客,是不是出现了奇迹呢 :biggrin: