1 Star 1 Fork 0

吴东元 / share-button

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

#share-button

![Foo](http://www.nafanlong.com/wp-content/uploads/2016/04/20160429165644.png)

上面是分享按钮的样式 ##DEMO ###一、这个项目就三部分组成:html、css和fontss 1、其中html部分如下:

<!DOCTYPE html>
<html>
<head>
<title>那樊笼-NFL button</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="css/share.css">
<body>
<!-- 分享  made by 那樊笼 www.nafanlong.com-->
<div class="share_1" style="width:20%;margin:200px auto;">
<ul class="social-share">
	<li><a href="http://v.t.sina.com.cn/share/share.php?url=<?php the_permalink(); ?>&title=<?php the_title(); ?>" target="_blank" rel="nofollow" class="social-share-icon icon-weibo" title="新浪微博"></a></li>
	<li><a href="" class="social-share-icon icon-wechat" title="微信朋友圈">
	    <div class="wechat-qrcode">
	      <h4>微信扫一扫:分享</h4>
	      <div class="qrcode" title="<?php the_permalink(); ?>"><img src="http://api.qrserver.com/v1/create-qr-code/?size=150x150&data=<?php the_permalink(); ?>" alt="<?php the_title(); ?>"/></div>
	      <div class="help"><p>微信里点“发现”,扫一下</p><p>二维码便可将本文分享至朋友圈。</p></div>
	    </div></a>
	</li>
	<li><a href="http://connect.qq.com/widget/shareqq/index.html?url=<?php the_permalink(); ?>&title=<?php the_title(); ?>" target="_blank" rel="nofollow" class="social-share-icon icon-qq" title="QQ好友"></a></li>
	<li><a href="http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=<?php the_permalink(); ?>&title=<?php the_title(); ?>" target="_blank" rel="nofollow" class="social-share-icon icon-qzone" title="QQ空间"></a></li>
	<li><a href="http://v.t.qq.com/share/share.php?title=<?php the_title(); ?>&url=<?php the_permalink(); ?>&site=<?php bloginfo('url');?>" target="_blank" rel="nofollow" class="social-share-icon icon-tencent" title="腾讯微博"></a></li>
	<li><a href="http://twitter.com/share?url=<?php the_permalink(); ?>&text=<?php the_title(); ?>" target="_blank" rel="nofollow" class="social-share-icon icon-twitter" title="Twitter"></a></li>
	<li><a href="http://facebook.com/share.php?u=<?php the_permalink(); ?>&t=<?php the_title(); ?>" target="_blank" rel="nofollow" class="social-share-icon icon-facebook" title="facebook"></a></li>
</ul>
</div>
</body>
</html>

除了微信其他都是个链接而已,没有要收的。微信分享用了国外的一个二维码API,它可以生成给定链接的二维码,用微信扫一下之后会出现在微信内置浏览器上,这时候就用到了微信内置浏览器中自带的微信分享功能(浏览器右上角有三个点,点击后就会出现分享的选项)。下面是用到的国外的API:

<img src="http://api.qrserver.com/v1/create-qr-code/?size=150x150&data=<?php the_permalink(); ?>" alt="<?php the_title(); ?>"/>

另外,上述html中的a标签里的 url=&title= 由于我用的wordpress所以这是wordpress里面的php变量,你们用的时候只要把**url=**后面的换成你们需要分享的文章链接,**titile=**后面换成你们要分享的文章名字就可以了,或者用你们设定的数据变量来取代。

2、css部分如下:

/************************
*** made by 那樊笼
***
*** url:www.nafanlong.com
***
*************************/
@font-face{font-family:"socialshare";
src:url("../fonts/iconfont.eot");
src:url("../fonts/iconfont.eot?#iefix") format("embedded-opentype"),url("../fonts/iconfont.woff") format("woff"),url("../fonts/iconfont.ttf") format("truetype"),url("../fonts/iconfont.svg#iconfont") format("svg")}
.social-share{font-family:"socialshare" !important;font-size:16px;font-style:normal;-webkit-font-smoothing:antialiased;-webkit-text-stroke-width:0.2px;-moz-osx-font-smoothing:grayscale;list-style: none;}
.social-share li{float: left;}
.social-share .icon-tencent:before{content:"\f07a"}
.social-share .icon-qq:before{content:"\f11a"}
.social-share .icon-weibo:before{content:"\f12a"}
.social-share .icon-wechat:before{content:"\f09a"}
.social-share .icon-douban:before{content:"\f10a"}
.social-share .icon-heart:before{content:"\f20a"}
.social-share .icon-like:before{content:"\f00a"}
.social-share .icon-qzone:before{content:"\f08a"}
.social-share .icon-linkedin:before{content:"\f01a"}
.social-share .icon-diandian:before{content:"\f05a"}
.social-share .icon-facebook:before{content:"\f03a"}
.social-share .icon-google:before{content:"\f04a"}
.social-share .icon-twitter:before{content:"\f06a"}
.social-share a{position:relative;text-decoration:none;margin:4px;display:inline-block;outline:none}
.social-share .social-share-icon{position:relative;display:inline-block;width:32px;height:32px;font-size:20px;border-radius:50%;line-height:32px;border:1px solid #666;color:#666;text-align:center;vertical-align:middle;transition:background 0.6s ease-out 0s}
.social-share .social-share-icon:hover{background:#666;color:#fff}
.social-share .icon-weibo{color:#ff763b;border-color:#ff763b}
.social-share .icon-weibo:hover{background:#ff763b}
.social-share .icon-tencent{color:#56b6e7;border-color:#56b6e7}
.social-share .icon-tencent:hover{background:#56b6e7}
.social-share .icon-qq{color:#56b6e7;border-color:#56b6e7}
.social-share .icon-qq:hover{background:#56b6e7}
.social-share .icon-qzone{color:#FDBE3D;border-color:#FDBE3D}
.social-share .icon-qzone:hover{background:#FDBE3D}
.social-share .icon-douban{color:#33b045;border-color:#33b045}
.social-share .icon-douban:hover{background:#33b045}
.social-share .icon-linkedin{color:#0077B5;border-color:#0077B5}
.social-share .icon-linkedin:hover{background:#0077B5}
.social-share .icon-facebook{color:#44619D;border-color:#44619D}
.social-share .icon-facebook:hover{background:#44619D}
.social-share .icon-google{color:#db4437;border-color:#db4437}
.social-share .icon-google:hover{background:#db4437}
.social-share .icon-twitter{color:#55acee;border-color:#55acee}
.social-share .icon-twitter:hover{background:#55acee}
.social-share .icon-diandian{color:#307DCA;border-color:#307DCA}
.social-share .icon-diandian:hover{background:#307DCA}
.social-share .icon-wechat{position:relative;color:#7bc549;border-color:#7bc549}
.social-share .icon-wechat:hover{background:#7bc549}
.social-share .icon-wechat .wechat-qrcode{display:none;border:1px solid #eee;position:absolute;z-index:9;top:-205px;left:-84px;width:200px;height:192px;color:#666;font-size:12px;text-align:center;background-color:#fff;box-shadow:0 2px 10px #aaa;transition:all 200ms;-webkit-tansition:all 350ms;-moz-transition:all 350ms}
.social-share .icon-wechat .wechat-qrcode h4{font-weight:normal;height:26px;line-height:26px;font-size:12px;background-color:#f3f3f3;margin:0;padding:0;color:#777}
.social-share .icon-wechat .wechat-qrcode .qrcode{width:105px;margin:10px auto}
.social-share .icon-wechat .wechat-qrcode .qrcode table{margin:0 !important}
.social-share .icon-wechat .wechat-qrcode .help p{font-weight:normal;line-height:16px;padding:0;margin:0}
.social-share .icon-wechat .wechat-qrcode:after{content:'';position:absolute;left:50%;margin-left:-6px;bottom:-13px;width:0;height:0;border-width:8px 6px 6px 6px;border-style:solid;border-color:#fff transparent transparent transparent}
.social-share .icon-wechat:hover .wechat-qrcode{display:block}

3、还有几个字体文件,可以自行下载。具体细节按自己需求来修改。目前只写出这些分享按钮(我认为目前比较流行的都在里面了),后期会看情况增加一些。

##以上就是全部内容,欢迎交流。

空文件

简介

之前我的网站上的分享按钮一直用的一个开源的组件,但是发现放到我的网站加载会出现一个小错误,强迫症的我实在无法忍受了,于是花了一些时间把代码缩减分离出来,只写我人为需要的,然后分享给大家。 目前网上的分享按钮,开源的很少,一般都是用百度分享、B-share或者JiaThis,这些开源组件用起来可玩性不高,而且它还加广告!它还加广告!它还加广告!重要的事情说3遍,不管是不是想推广自己,身为患有强迫癌的程序员,眼里容不得沙子! 展开 收起
HTML
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
HTML
1
https://gitee.com/wdy_/share-button.git
git@gitee.com:wdy_/share-button.git
wdy_
share-button
share-button
master

搜索帮助