百度360必应搜狗淘宝本站头条
当前位置:网站首页 > IT知识 > 正文

ASP.NET MVC+Bootstrap个人博客之文章打赏(六)

liuian 2024-12-30 05:16 21 浏览

看到新浪微博、百度百家等等平台上都带有文章“打赏”功能,觉得很新鲜,于是也想在自己的博客中加入“打赏”功能。

当然,加入打赏功能并非是真的想要让别人打赏。因为只有那些真正能引起共鸣,发人深思,让人受益匪浅的文章才值得打赏,值得点赞。

而我的博客站仅仅是用作记录笔记,当做自己的知识库(如果能不经意间帮助别人那是再好不过了)。

加入打赏功能纯粹是“觉得好玩”,就是这么简单,Just have a fun!(博主喜欢折腾,看见一个酷炫的功能就想去实现它)

先看一下这个打赏的Icon长什么样吧! 去站点试试打赏?=>www.zynblog.com

点击“打赏Icon”后会弹出一个二维码界面,各位老板可以选择使用是使用支付宝打赏还是微信打赏:

具体代码如下:(时间仓促,并为将其扩展为插件)

HTML:

        <!--打赏按钮-->
        <div style="margin-bottom:20px;">
         <a title="打赏,支持一下" class="dashang" onclick="dashangToggle" href="javascript:void(0)">

         </a>
        </div>

打赏遮罩层HTML:

<div class="content">
    <div class="hide_box"><!--遮罩--></div>
    <div class="shang_box">
        <a class="shang_close" href="javascript:void(0)" onclick="dashangToggle" title="关闭">
 <img src="/Content/dashangimg/close.jpg" alt="取消">
        </a>
        <div class="shang_tit">
 <p>感谢您的支持,我会继续努力的!</p>
        </div>

        <div class="shang_payimg">
 <img src="/Content/dashangimg/alipayimg.jpg" alt="扫码支持" title="扫一扫">
        </div>
        <div class="pay_explain">扫码打赏,你说多少就多少</div>

        <div class="shang_payselect">
 <div class="pay_item checked" data-id="alipay">
 <span class="radiobox"></span>
 <span class="pay_logo">
 <img src="/Content/dashangimg/alipay.jpg" alt="支付宝">
 </span>
 </div>
 <div class="pay_item" data-id="weixinpay">
 <span class="radiobox"></span>
 <span class="pay_logo">
 <img src="/Content/dashangimg/wechat.jpg" alt="微信">
 </span>
 </div>
        </div>

        <div class="shang_info">
 <p>打开<span id="shang_pay_txt">支付宝</span>扫一扫,即可进行扫码打赏哦</p>
        </div>
    </div>
</div>

主要的JS:

 //打赏
jQuery(".pay_item").click(function {
jQuery(this).addClass('checked').siblings('.pay_item').removeClass('checked');
var dataid = jQuery(this).attr('data-id');
jQuery(".shang_payimg img").attr("src", "/Content/dashangimg/" + dataid + "img.jpg");
jQuery("#shang_pay_txt").text(dataid == "alipay" ? "支付宝" : "微信");
});
function dashangToggle {
jQuery(".hide_box").fadeToggle;
jQuery(".shang_box").fadeToggle;
};

顺带提供CSS:

  1 .hide_box {
  2     z-index: 999;
  3     filter: alpha(opacity=50);
  4     background: #666;
  5     opacity: 0.5;
  6     -moz-opacity: 0.5;
  7     left: 0;
  8     top: 0;
  9     height: 99%;
 10     width: 100%;
 11     position: fixed;
 12     display: none;
 13 }
 14 
 15 .shang_box {
 16     width: 540px;
 17     height: 540px;
 18     padding: 10px;
 19     background-color: #fff;
 20     border-radius: 10px;
 21     position: fixed;
 22     z-index: 1000;
 23     left: 50%;
 24     top: 50%;
 25     margin-left: -280px;
 26     margin-top: -280px;
 27     border: 1px dotted #dedede;
 28     display: none;
 29 }
 30 
 31     .shang_box img {
 32         border: none;
 33         border-width: 0;
 34     }
 35 
 36 .dashang {
 37     display: block;
 38     margin: 5px auto;
 39     text-align: center;
 40     transition: all 0.3s;
 41     width:50px;
 42     height:50px;
 43      background: url(../dashangimg/dashang.png) no-repeat scroll 0% 0% transparent;
 44 }
 45 
 46 .dashang:hover {
 47         background: url(../dashangimg/dashanghover.png) no-repeat scroll 0% 0% transparent;
 48     }
 49 
 50 .shang_close {
 51     float: right;
 52     display: inline-block;
 53 }
 54 
 55 .shang_logo {
 56     display: block;
 57     text-align: center;
 58     margin: 20px auto;
 59 }
 60 
 61 .shang_tit {
 62     width: 100%;
 63     height: 75px;
 64     text-align: center;
 65     line-height: 66px;
 66     color: #a3a3a3;
 67     font-size: 16px;
 68     background: url('../dashangimg/cy-reward-title-bg.jpg');
 69     font-family: 'Microsoft YaHei';
 70     margin-top: 7px;
 71     margin-right: 2px;
 72 }
 73 
 74     .shang_tit p {
 75         color: #a3a3a3;
 76         text-align: center;
 77         font-size: 16px;
 78     }
 79 
 80 .shang_payimg {
 81     width: 150px;
 82     height: 150px;
 83     border: 6px solid #EA5F00;
 84     margin: 0 auto;
 85     border-radius: 3px;
 86 }
 87 
 88     .shang_payimg img {
 89         display: block;
 90         text-align: center;
 91         width: 140px;
 92         height: 140px;
 93     }
 94 
 95 .pay_explain {
 96     text-align: center;
 97     margin: 10px auto;
 98     font-size: 12px;
 99     color: #545454;
100 }
101 
102 .radiobox {
103     width: 16px;
104     height: 16px;
105     background: url('../dashangimg/radio2.jpg');
106     display: block;
107     float: left;
108     margin-top: 5px;
109     margin-right: 14px;
110 }
111 
112 .checked .radiobox {
113     background: url('../dashangimg/radio1.jpg');
114 }
115 
116 .shang_payselect {
117     text-align: center;
118     margin: 0 auto;
119     margin-top: 40px;
120     cursor: pointer;
121     height: 60px;
122     width: 280px;
123 }
124 
125     .shang_payselect .pay_item {
126         display: inline-block;
127         margin-right: 10px;
128         float: left;
129     }
130 
131 .shang_info {
132     clear: both;
133 }
134 
135     .shang_info p, .shang_info a {
136         color: #C3C3C3;
137         text-align: center;
138         font-size: 12px;
139         text-decoration: none;
140         line-height: 2em;
141     }

打赏样式

相关推荐

用python操作excel、word、pdf非常容易,迅速教会你

你会用python操作excel、word、pdf吗?不会也没关系,这篇文章教会你~【文末领取】案例篇幅有限,给大家准备了电子版PDF获取方式:...

不同类型的文本、Word文档、Excel文档和图片将它们转换为PDF格式

要根据不同类型的文本、Word文档、Excel文档和图片将它们转换为PDF格式,你可以使用Python中的不同库来实现。下面是一个示例代码,展示了如何使用不同的库来处理不同类型的文件并将其转换为PDF...

10分钟实现PDF转Word神器!看DeepSeek如何用Python解放打工人

开篇痛点每个被PDF折磨过的职场人都懂——领导发来的扫描件要修改,手动抄到Word需要2小时;网上下载的报告想复制数据,却变成乱码…今天我们用Python+DeepSeek,10分钟打造一个智能转换工...

第12天 | 12天搞定Python,word和pdf

其实,Python除了对excel的支持很nice之外,对word、ppt和pdf也不赖的,上一篇《第12天|12天搞定Python,让excel飞起来》说了excel方面的内容,这一篇补上Py...

用python轻松操作excel、word、pdf吗?这篇文章教会你!拿走不谢

你会用python操作excel、word、pdf吗?不会也没关系,这篇文章教会你~【文末领取】案例篇幅有限,给大家准备了电子版PDF获取方式:...

Python开发打印服务(1)

Python开发打印服务(1)1.需求背景在项目开发中,我们经常会遇到打印预览、打印的需求。比如:我们在开发进销存或者其他系统应用时,经常会按照客户的需求来定制报表等。在Web项目中,实现打印预览...

零代码编程:用ChatGPT将PDF文件的表格批量转为Excel表格

电脑中有几百个PDF文件,文件内容格式一致,每个PDF文件第一页是一个表格。想把这几百个PDF文件里面的表格都提取出来,转为excel表,该怎么办?打开ChatGPT(一定要用GPT4,编程能力很强。...

用python操作excel、word、pdf非常迅速方便,迅速教会你

你会用python操作excel、word、pdf吗?不会也没关系,这篇文章教会你~【文末领取】案例篇幅有限,给大家准备了电子版PDF获取方式:...

PDF转换技巧:如何免费将 PDF 转换为 Excel

随着数字文档的使用不断增加,对高效和值得信赖的文档转换工具的需求也在增加。将PDF文件转换为Excel电子表格(XLS)可能具有挑战性,但这篇文章旨在缓解这些困难。这是带有分步说明的指南。...

PDF转Excel要收费?python几行代码帮你免费搞定(附代码)

写在前面经常在学习或工作中需要从PDF获取一些表格数据,直接用PDF阅读器复制的话,很难复制出来,使用PDF转Excel的软件,又需要收费。这时候,可以使用我们强大的python,几行代码就能把pdf...

python将PDF格式文档转换为excel文档

首先安装pdfplumber库pipinstallpdfplumberopenpyxl然后转换#导入两个模块importpdfplumberimportpandasaspd...

用DEEPSEEK写PDF转为Excel 程序

今天学校发了《2027通用版普通高校拟在山东招生专业(类)选考科目要求》(本科)文件为PDF版要转为化Excel用DEEPSEEK开发过程提问:写一个把PDF内容按着原来格式转化为EXCELL表格电脑...

用DeepSeek+Trae 自己写PDF表格转为EXCEL表格

如何将下面PDF表格转为EXCEL能更好统计在TRAE提问:新建窗口-选择文件夹-写一个PDF转excel电脑程序:样式不变,界面有选择文件,有输出文件,显示进度及页码,开始,暂停,退出,实现所...

Python一行代码实现PDF转Excel

第三方包tabula工具适用于从PDF中提取可复制(非图片格式)的表格数据,并输出表格安装pipinstalltabula-py函数调用df=tabula.read_pdf("PDF文件...

Python教程:python字典zip函数用法 - 学习如何操作字典

知识星球:写代码那些事如果你有收获|欢迎|点赞|关注|转发这里会定期更新|大厂的开发|架构|方案设计这里也会更新|如何摸鱼|抓虾欢迎来到写代码那些事!在Python编程中,字典(Dictionary)...