添加一個位置固定的百度分享按鈕

百科知道評論2,011閱讀模式

添加一個位置固定的百度分享按鈕

HotNews Pro 2.72集成的固定在頁面左側的百度分享按鈕,可方便讀者分享自己喜歡的文章,本文教你把這個固定的分享按鈕添加到其它主題中。

第一步,在你所用主題目錄新建一個名稱為:share.php的模板文件,將下面的代碼復制到進去并保存:

  1. <div id="share">
  2. <div class="share">
  3. <div id="bdshare"class="bdshare_t bds_tools get-codes-bdshare">
  4. <a class="bds_tsina"></a>
  5. <a class="bds_tqq"></a>
  6. <a class="bds_qzone"></a>
  7. <a class="bds_renren"></a> 
  8. <span class="bds_more"></span>
  9. </div>
  10. <div style="clear:both;"></div>
  11. </div>
  12. </div>
  13. <script type="text/javascript" id="bdshare_js" data="type=tools&amp;uid=0" ></script>
  14. <script type="text/javascript" id="bdshell_js"></script>
  15. <script type="text/javascript">
  16. document.getElementById("bdshell_js").src = "http://bdimg.share.baidu.com/static/js/shell_v2.js?cdnversion=" + Math.ceil(newDate()/3600000)
  17. </script>
  18. <style type="text/css">
  19. #share {
  20. display:block;
  21. width:35px;
  22. margin-left:-546px;/* 修改左右位置 */
  23. position:fixed;
  24. left:50%;
  25. top:420px;/* 修改上下位置 */
  26. _margin-left:-546px;/* IE6修改左右位置 */
  27. _position:absolute;
  28. _margin-top:420px;/* IE6修改上下位置 */
  29. _top:expression(eval(document.documentElement.scrollTop));
  30. }
  31. .share {
  32. background:#fff;
  33. width:24px;
  34. border: 1px solid #ccc;
  35. border-radius:5px 0 0 5px;
  36. }
  37. #bdshare_l {
  38. border-radius: 5px;
  39. }
  40. div #bdshare_l_c {
  41. border: 1px solid #ccc;
  42. border-radius: 5px;
  43. }
  44. #bdshare h6, #bdshare_s h6,#bdshare p, #bdshare_s p {
  45. display:none;
  46. }
  47. </style>

第二步,將調用代碼:

  1. <?php include('share.php'); ?>

添加到主題頁腳模板footer.php這句上面:

  1. <?php wp_footer(); ?>

以上代碼在WP默認主題Twenty Twelve中測試通過,針對不同主題的頁面寬度,可適當調整固定按鈕的位置,代碼中有注釋。

添加更多的百度分享網站按鈕點此查看方法

 
  • 本文由 米粒在線 發表于 2014年6月17日13:33:04
  • 轉載請務必保留本文鏈接:http://m.bjmhhq.com/24541.html
百科知道

徹底解決AMD顯卡win10開機黑屏問題

遇上個AMD R7 350 顯卡 偶爾開機到了logo之后黑屏,找了各種法子沒解決,看到了這個辦法。試試看。來自小櫻看科技的公眾號。這邊做一下記錄避免丟了。謝謝。小櫻的辦公用電...

發表評論

匿名網友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
確定

拖動滑塊以完成驗證