How to Add Floating Share Buttons Widget to Blogger

In this tutorial we will only use HTML and CSS to add fixed and floating share buttons widget to Blogger. It is best in its kind as it requires minimum effort to implement and is also very stable.

Floating share buttons

Step 1: Go to Template tab of your blog on Blogger and click “Edit HTML”. Now check “Expand Widget Templates”.

Step 2: Add the below codes above ]]></b:skin>:

#sharebox {
 float: left;
 margin-left: -80px;
 position: fixed;
 background: #f5f5f5;
 border:1px solid #ccc;
 -moz-border-radius:5px;
 border-radius:5px;
}
#sharebox .wdt {
 float: left;
 clear: left;
 padding: 5px;
 text-align: center;
}

Step 3: Find <data:post.body/> and before this add:

<b:if cond='data:blog.pageType == "item"'>
<div id='sharebox'>
<!-- Tweet Button -->
<div class='wdt'><a class='twitter-share-button' data-count='horizontal' data-via='blogger_Raju' expr:data-text='data:post.title' expr:data-url='data:post.canonicalUrl' href='http://twitter.com/share'>Tweet</a><script src='//platform.twitter.com/widgets.js' type="text/javascript"></script></div>
<!-- Facebook Like (XFBML) -->
<div class='wdt'><div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like font="lucida grande" expr:href="data:post.canonicalUrl" send="true" layout="box_count" show_faces="false" width="55"></fb:like></div>
<!-- Plus One -->
<div class='wdt'><g:plusone size='tall' expr:href='data:post.canonicalUrl'></g:plusone><script src='https://apis.google.com/js/plusone.js' type="text/javascript"></script></div>
<!-- Pinterest -->
<div class='wdt'><b:if cond='data:post.thumbnailUrl'><a class='pin-it-button' count-layout='horizontal' expr:href='"http://pinterest.com/pin/create/button/?url=" + data:post.url + "&amp;media=" + data:post.thumbnailUrl + "&amp;description=" + data:post.title'>Pin It</a><b:else/><a class='pin-it-button' count-layout='horizontal' expr:href='"http://pinterest.com/pin/create/button/?url=" + data:post.url + "&amp;media=http://your-image.jpg&amp;description=" + data:post.title'>Pin It</a></b:if><script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script></div>
</div>
</b:if>

Step 4: Preview your template if it is not giving any XML error (I hope not) then Save it.

Setting and Customization:
  • You can set whether you want this widget to float closer or farther away form the post body by increasing or decreasing the default pixels value, that is, -80px.
  • The third step is just an example. Some button scripts needs to be added properly so that it renders correctly and progressively. So don't forget to browse through button counter to find out how it should be done.
  • Here I have included the famous share buttons only, but you can also add some extra ones too. See the example below:
    <b:if cond='data:blog.pageType == "item"'>
    <div id='sharebox'>
    <div class='wdt'>Digg</div>
    <div class='wdt'>StumbleUpon </div>
    <div class='wdt'>Example</div>
    </div>
    </b:if>

    All you have to do is add your button scripts between <div class='wdt'> and </div>.

Popular posts from this blog

How to Resize Blogger Header to Logo Size

Create your own Contact Form with Kontactr for Blogger

Add Google Website Translator to Blogger