Align Google +1, Tweet, Like and Pin It buttons horizontally
Update Feb. 2012: Added Pinterest Pin It button.
Even though Facebook Like & Send, Twitter Tweet and Google +1 social sharing buttons can be added easily enough 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.
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:
- Go to Design > Edit HTML (New interface: Template > Edit HTML).
- Back up your template.
- Tick the Expand Widget Templates checkbox on top right of the code window.
- Next, look for
<data:post.body/>tag and paste the following code immediately above it:<!-- 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); js.id = id; js.src = "http://connect.facebook.net/en_US/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); </script> <!-- Google +1 --> <script type='text/javascript'> (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })(); </script> <!-- Twitter --> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> </b:if> <!-- 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='https://twitter.com/share'>Tweet</a> </div> <!-- Google +1 --> <div style='float:left;'> <g:plusone annotation='bubble' expr:href='data:post.url' size='medium'/> </div> <!-- 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'/> </div> <!-- Pinterest Start --> <b:if cond='data:blog.pageType == "item"'> <div id='pin-wrapper' style='display: inline;'> <a class='pin-it-button' count-layout='horizontal' expr:href='"http://pinterest.com/pin/create/button/?url=" + data:post.url'>Pin It</a> <a href='javascript:void(run_pinmarklet())' style='margin-left:-93px; width:43px; height:20px; display:inline-block;'/> </div> <script src='http://assets.pinterest.com/js/pinit.js' type='text/javascript'></script> <script type='text/javascript'> function run_pinmarklet() { var e=document.createElement('script'); e.setAttribute('type','text/javascript'); e.setAttribute('charset','UTF-8'); e.setAttribute('src','http://assets.pinterest.com/js/pinmarklet.js?r=' + Math.random()*99999999); document.body.appendChild(e); } </script> </b:if> <!-- Pinterest End --> </div> <div style='clear: both;'/> <!-- Horizontal social buttons End -->All buttons will appear on all pages with the exception of Pinterest Pin It button, which will appear only on post pages.
- Button positioning
To position the buttons at the bottom of post, place the code below (instead of above)<data:post.body/>. - Preview before saving.
Enjoy!
p.s. If you wish you can also align share buttons vertically on the side of your blog.
47 comments to "Align Google +1, Tweet, Like and Pin It buttons horizontally"
Bagaimanaa yang dah gunakan
widget dari ADD THIS tapi
tak align..boleh guna tak
tutorial ni :)
its better. thanks for it greenlava.
how to edit codes if I want to show counter on the top of share button not right side
hi Good day!
First I would like to thank you for your helpful tips, I've even used your Simply Faster Template for my blog here: http://www.makkopals.com/
My question is, from the Simply Faster Template i saw 3 to where should I post your code?
thanks for the share
Works fine! Thank you
@zulkbo
Saya tak pasti, tapi boleh cuba letak kod AddThis button spt di bawah:
[div style='float:left;']
LETAK KOD SINI
[/div]
lepas tu insert kod di atas selepas line 39.
@ehl-i blog
To customize individual buttons, visit their respective tutorials. The links are given at the beginning of this post.
@makko
For Simply Faster Template, you'll have to add the code at two (out of three) places. Both places are located between these comments:
< !-- multipost pages conditional -->
DO YOUR STUFF HERE
< !-- multipost pages conditional -->
Hi Greenlava,
Thanks so much for all the helpful information you share with us! I'm wondering if there's a way to use your code but with different buttons? For example, I would love to have these buttons horizontally aligned at the top of each of my posts:
Facebook like
tweet
stumbleupon
pinterest
Thanks! :)
I got it working Thank You Very Much!!! you are a star and expect me to follow all your post... i am trying to learn everything from here... thanks again mate ^_^
The code that you say to place this in front of, [data:post.body/] is not found anywhere in the html for my blog. I use blogger if that helps you any.
Searched on the whole string, then tried post, then tried body. Is there something else it might say?
i have stumble upon and pinterest buttons already- where do I add them in the above code?
Thanks for the help- this has been vexing me too!
I got it working, hope you'll not get tired sharing helpful tips... I wish you more blessings!! Thanks you Sir!
Hi again,
I have another question. Do you take requests for post topics? :)
I've just spent several (more) hours unsuccessfully trying to add a 'pin this' Pinterest button to the top of each of my Blogger blog posts, next to the Facebook 'like' button I already have up there. The official pinterest button code (found here: http://pinterest.com/about/goodies/) apparently doesn't work for individual Blogger posts, and several other instructions and codes I found online don't work either.
I bet you could figure out how to install that pesky button - and I'm sure I'm not the only one who would be eternally grateful. Thanks for considering it - and for all the help you've already given us! :)
You're right, everybody knows how to put these buttons but never aligned properly. Thanks for the share, this is really a valuable information. I will try it right now on my blog and see if its gonna work out fine.
Wrote a comment here the other day...don't see it!
My html on blogger does not have
Is there another string I should look for?
@Farmgirl Susan
@nicole / Twitter: BTHM1
If you notice, each button code is wrapped in a div tag, like this:
[div style='float:left;']
SHARE BUTTON CODE
[/div]
so if you want to replace a button, just replace the respective button code with the new button code.
To add a button, simply insert the new button code (wrapped with a div tag like above)right after line 39.
@Gerry Wendel
Have you checked the Expand Widget Templates checkbox before looking for the code?
Hi Greenleave, I'm setting up a site right now and I got a lot of ideas on how to input buttons on one's site. Instead of reading through those articles, I'll be following this concise set of instructions you have on your article. I'ts nice of you to share brief ideas.
Great, thanks. So in order to install a totally different button (for stumbleupon, etc.) would anything need to be changed or added in lines 1 - 24 as well?
If you want to change the facebook like/send button to just a facebook like button, would anything need to be changed in lines 1-24?
Thanks so much. :)
Thanks so much for all your tips!
Just copied to put in my blog - and the Facebook icon isn't working. Twitter and Google+ are. Any thoughts?
Also - I have a floating share button that I HATE and cannot figure out how to delete it.
Greenlava, thank you for this helpful information. This is very important as social media widgets are important parts of any blog.
@Farmgirl Susan
Most button codes consist of two parts -one part is a script and the other one is a HTML.
For best result put the script part within lines 1-24 and the HTML part after line 39. The purpose is to prevent multiple script loadings on multi-post pages.
That said if you were to put the script and HTML together (as in my previous reply), that should work too.
To show Facebook Like without Send, change send='true' to send='false' (line 38).
Thanks for sharing this critical information with your readers. I look forward to reading more and more from your blog.
Nice entry indeed..
btw i just voted for you for Worlds Bloggers And Social Media Awards 2012.. All the best ya... =)
Plsssss vote me back for THE WORST BLOG OF THE YEAR @http://socialmediaweek.com.my/awards/category.php?id=33 "click vote di link www.bicaramakdara.com ye Thank youuuu =)
@ADZA IRDAWATI aka MAK DARA
Thanks for voting.
Voted yours.
Thanks for the help! :)
thanks for all your share!
Yes, it worked now...thanks!
I followed everything but I have a problem. The Facebook button is not visible along with the two other buttons. I hope you can help me on this.
Thank you in advance.
Jouie
@Jouie
It looks fine from here.
thanks for ur post. it worked now.
Salam Blogger.
Situs ini banyak memberikan kontribusi ilmu yang bermanfaat buat kami.
Terimakasih
The google plus logo isn't showing for me. Any help?
Simple tip but very useful !!
I would LOVE to see the pinterest button added to the 3 above. Any way to do that?
Hello.
I removed the google+ button and now the tweet and facebook buttons are touching eachother. How do I put a bit of space between them?
Thanks so much!
www.erinfayephotographyblog.blogspot.com
@Erin Faye
Add a right margin to each button by replacing:
[div style='float:left;']
with this:
[div style='float:left; margin-right: 15px;']
Hello. I am new to this and I need your assistance please. I have a new site. I want to deactivate the current plugin in my site and then get your horizontal look code above the post as a replacement. I'm using a wordpress blog. Where do I put the code? Thanks!
@Greenlava - do you have any idea why the Google +1 button sometimes shows and sometimes doesn't? I've made some changes on my blog to reposition Linkwithin (as suggested by you) and briefly the Google +1 button actually showed, which it hadn't before, but now it's disappeared again. It's almost as if I didn't change anything in that particular code. Code it be my browser or something on the Google side? My blog: http://joburgexpat.blogspot.com. Thanks!
the way u expressed post is just awesome!!
I loaded the script onto my page and it works great. It however is a little too close to the body and looks to close. How can I add some padding to the bottom to space it out. Thanks!
@Tom
Increase the padding in line 27:
padding:5px 0 5px;
The second "5px" is the value for the bottom padding.
@Ryan Armbrust
Pinterest Pin It button added.
I've experimented my blog on posting social buttons like the Twitter, Facebook Like and so on 'caused I couldn't perfect it. Now I've found your simple, helpful tips which I right away adapted it in my blog. Thank you very much. I really appreciate your tips - a resourceful tips for this matter. Now they're are neatly done and orderly posted in all of my blog posts.
Thanks for this, very helpful. I was able to use your codes immediately!
If your question is unrelated to this article, please use our Facebook page.
When posting HTML/XML code, replace < and > symbols with [ and ] respectively. The reverse applies when copying code from my replies here.