Dec 15, 2015

Align Google +1, Tweet, Like and Pin It buttons horizontally

Even though individual Facebook Like & SendTwitter TweetGoogle +1Pinterest Pin It, and social sharing buttons can be easily added to Blogger post by following their respective tutorials, aligning them perfectly side by side is a bit tricky. Several readers were having trouble with the alignment and contacted me for help.
twitter google  1 like send pinterest buttons
Rather than attempting to explain how to align your existing buttons, I think it’s easier to just give you a new set of codes for the buttons with the alignment built in. Simply remove your existing buttons and add the new code using the following steps:

[30 Nov 2012] Update code to fix Pin It button not pulling thumbnail problem.
[Feb 2012] Add Pinterest Pin It button.
  1. Go to Template > Edit HTML.
  2. Back up your template.
  3. Tick the Expand Widget Templates checkbox on top right of the code window.
  4. Next, locate the first instance of <data:post.body/> tag and paste the following code immediately above it:
  5. <!-- Scripts Start -->
    <b:if cond='data:post.isFirstPost'>
    <!-- Facebook -->
    <div id='fb-root'/>
    <script>(function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) {return;}
    js = d.createElement(s); = id;
    js.src = &quot;;;
    fjs.parentNode.insertBefore(js, fjs);
    }(document, &#39;script&#39;, &#39;facebook-jssdk&#39;));
    <!-- Google +1 -->
    <script type='text/javascript'>
    (function() {
    var po = document.createElement(&#39;script&#39;); po.type = &#39;text/javascript&#39;; po.async = true;
    po.src = &#39;;;
    var s = document.getElementsByTagName(&#39;script&#39;)[0]; s.parentNode.insertBefore(po, s);
    <!-- Twitter -->
    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);;js.src=&quot;//;;fjs.parentNode.insertBefore(js,fjs);}}(document,&quot;script&quot;,&quot;twitter-wjs&quot;);</script>
    <!-- Scripts End -->
    <!-- Horizontal social buttons Start -->
    <div class='horizontal-social-buttons' style='padding:10px 0 10px;'>
    <!-- Twitter -->
    <div style='float:left;'>
    <a class='twitter-share-button' data-count='horizontal' data-lang='en' data-related='' data-via='' expr:data-text='data:post.title' expr:data-url='data:post.url' href=''>Tweet</a>
    <!-- Google +1 -->
    <div style='float:left;'>
    <g:plusone annotation='bubble' expr:href='data:post.url' size='medium'/>
    <!-- Facebook Like+Send -->
    <div style='float:left;'>
    <fb:like colorscheme='light' expr:href='data:post.url' font='' layout='button_count' send='true' show_faces='false'/>
    <!-- Pinterest Start -->
    <b:if cond='data:blog.pageType == &quot;item&quot;'>
    <div id='pin-wrapper' style='float: left; margin:0px 0px 0px 30px; width:44px;'>
    <a data-pin-config='beside' data-pin-do='buttonPin' expr:href='&quot;; + data:post.url'><img src='//'/></a>
    <span style='margin-left:-44px;'><a data-pin-config='beside' data-pin-do='buttonBookmark' href='//' style='outline:none;border:none;'/></span>
    <script src='' type='text/javascript'></script>
    <style type='text/css'> 
    #pin-wrapper > a {background-image:none !important;}
    <!-- Pinterest End -->
    <div style='clear: both;'/>
    <!-- Horizontal social buttons End -->
  6. Note:
    • Pin It button will only appear on post pages. We place this limit  because the button only pins the page on which it appears. As such  on homepage (if we were to allow it there), every instance of the button will pin the homepage, not the post (as it’s “supposed” to).
    • The Pinterest script in line 45 must occur only once in your blog. Omit this line if you’ve already had the script in your blog.
  7. Buttons positioning 
    To position the buttons at the bottom of post, place the code below (instead of above) <data:post.body/>
  8. Preview before saving.



Post a Comment

Nam Le © 2014 - Designed by, Distributed By Templatelib