So, I have decided to create a set of top social buttons (Facebook, Google & Twitter), which will load only when user decides to share your content, otherwise we do not load them.
I have created two files for this example, one is regular HTML file where our share buttons will be loaded, other one is a PHP file which will accept Ajax request and return the set of share buttons.
You need to place this HTML code within your page where you want share button to appear. Since its CSS position will be “fixed“, you can place it anywhere within BODY part of your page and play a bit with “sw-share-wrp” class in CSS section to adjust its final position.
Since the arrival of CSS3, we can create so many nifty effects just using CSS3. So, why not give a nice rotating animation to share icon using this technology? Let’s spin our share icon on mouse hover. The CSS3 code below makes our share icon spin clockwise and anticlockwise, but we want to control it using jQuery event rather than regular CSS :hover, you will find rest of the CSS in sample file.
Here’s jQuery part of the example, we will basically load social buttons using jQuery Ajax when a user hovers the mouse over the share icon, and then to have CSS3 spin effect, we just add and remove “xspin” and “yspin” classes to sw-share-icon element.
PHP part is pretty straight forward, I have added 3 top social buttons here, you can add other share buttons such as linkedin, digg etc. if you want, but I haven’t tested their functionality with Ajax, I am pretty sure they will too work just fine!
That’s it, you can download the sample files by clicking link below, and to see live demo just hover over the icon top left of this page, all the best!