自制简易打赏功能的实例
程序员文章站
2022-05-14 19:01:56
1、申请开通cnblogs的js代码支持
2、将微信收款码图片上传到cnblogs
3、将如下代码中的http://files.cnblogs.com/file...
1、申请开通cnblogs的js代码支持
2、将微信收款码图片上传到cnblogs
3、将如下代码中的http://files.cnblogs.com/files/eritpang/weixin.bmp替换为刚刚上传的收款码图片的链接地址,然后将代码添加到设置->博客侧边栏公告(支持html代码)(支持js代码)里面,再点击“保存”即可。
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html;" /> <title>打赏</title> <style type="text/css"> #dssidebar { z-index: 999999; top: 18%; width: 200px; height: 200px; position: fixed; right: -200px; } #dsbtn { z-index: 999999; width: 30px; height: 58px; left: -30px; top: 80px; line-height: 28px; position: absolute; } .dspanels { margin: 0px auto; overflow: hidden; } .dspanel { float: left; margin: 0px 0px; padding: 12px 0px; text-align: center; background: #ffeedd; border-color: #ffeedd; border-radius: 8px; } .dspanel-highlight { margin-top: 0; margin-bottom: 0; padding-left: 10px; padding-right: 10px; width: 160px; border: 8px solid #fd935c; } .dspanel-button { display: block; font-size: 16px; font-weight: 500; color: #ffeedd; text-align: center; text-decoration: none; text-shadow: 0 1px rgba(black, .1); background: #fd935c; border-bottom: 2px solid #cf7e3b; border-color: rgba(black, .15); border-radius: 4px; } .dspanel-title { width: 128px; margin: -15px auto 15px; padding-bottom: 0px; line-height: 22px; font-size: 14px; font-weight: bold; color: #ffeedd; text-shadow: 0 1px rgba(black, .05); background: #fd935c; border-radius: 0 0 4px 4px; } </style> <script> function movebtn() { var dsbtn = document.getelementbyid("dsbtn"); var now = new date(); var times = now.gettime(); var offsetsize = math.sin(times / 380.0) * 15 + 45; var radius = math.sin(times / 380.0) * 18 + 24; dsbtn.style.left = -offsetsize + 'px'; dsbtn.style.width = offsetsize + 'px'; dsbtn.style.borderradius = radius + 'px'; settimeout(movebtn, 60); } var dssidebartimer = null; var dssidebaroffsetright = -200; function startmove(dssidebartarget, dssidebarspeed) { cleartimeout(dssidebartimer); function domove() { var dssidebar = document.getelementbyid('dssidebar'); dssidebarspeed *= 0.9; if (dssidebarspeed > -1 && dssidebarspeed < 0) { dssidebarspeed = -1; } else if (dssidebarspeed < 1 && dssidebarspeed > 0) { dssidebarspeed = 1; } dssidebaroffsetright = dssidebaroffsetright + dssidebarspeed; if (dssidebarspeed > 0 && dssidebaroffsetright >= dssidebartarget) { dssidebaroffsetright = dssidebartarget; dssidebar.style.right = dssidebaroffsetright + 'px'; } else if (dssidebarspeed < 0 && dssidebaroffsetright <= dssidebartarget) { dssidebaroffsetright = dssidebartarget; dssidebar.style.right = dssidebaroffsetright + 'px'; } else { dssidebar.style.right = dssidebaroffsetright + 'px'; dssidebartimer = settimeout(domove, 30); } } domove(); } document.getelementbyid('dsimg').onload = function () { var dssidebar = document.getelementbyid('dssidebar'); dssidebar.onmouseover = function () { startmove(0, 24); } dssidebar.onmouseout = function () { startmove(-200, -24); } movebtn(); } </script> </head> <body> <div id="dssidebar"> <div class="dspanels"> <div class="dspanel dspanel-highlight"> <p class="dspanel-title">喜欢请用微信打赏</p> <img id='dsimg' src="http://files.cnblogs.com/files/eritpang/weixin.bmp" alt="" width="160" height="160" /> </div> </div> <span class="dspanel-button" id='dsbtn'><b>打<br/>赏</b></span> </div> </body> </html>
4、效果如下。
以上这篇自制简易打赏功能的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
上一篇: 十个免费的web前端开发工具详细整理