Remember: This works pretty well with all kinds of widgets present in your sidebar. It is not necessary that a person can only use if for email subscription boxes. You can use it for promotion of your items, galleries, popular posts, Instagram photos, and basically everything that you wish for.
Step#1: Adding a New Widget:
The First thing you need to do is to add a new widget in your sidebar so that later on you can make it sticky. Go to Blogger.com >> Layout >> Add a Gadget >> Add HTML/JavaScript >> and name the widget as “My Sticky Gadget”. Now writing anything in the HTML body and once everything is down press “Save” button located at the end of the page.Step#2: Installing a “Sticky” Plugin:
Now after properly adding a new widget in your blog, it’s time for some serious work. This time go to Template >> Edit HTML >> and search for the ending </body> tag and just above it paste the following JavaScript code.<script>
/*<![CDATA[*/
// Sticky Plugin
// =============
// Author: Syed Faizan Ali
(function($) {
var defaults = {
topSpacing: 0,
bottomSpacing: 0,
className: 'is-sticky',
center: false
},
$window = $(window),
$document = $(document),
sticked = [],
windowHeight = $window.height(),
scroller = function() {
var scrollTop = $window.scrollTop(),
documentHeight = $document.height(),
dwh = documentHeight - windowHeight,
extra = (scrollTop > dwh) ? dwh - scrollTop : 0;
for (var i = 0; i < sticked.length; i++) {
var s = sticked[i],
elementTop = s.stickyWrapper.offset().top,
etse = elementTop - s.topSpacing - extra;
if (scrollTop <= etse) {
if (s.currentTop !== null) {
s.stickyElement.css('position', '').css('top', '').removeClass(s.className);
s.currentTop = null;
}
}
else {
var newTop = documentHeight - s.elementHeight - s.topSpacing - s.bottomSpacing - scrollTop - extra;
if (newTop < 0) {
newTop = newTop + s.topSpacing;
} else {
newTop = s.topSpacing;
}
if (s.currentTop != newTop) {
s.stickyElement.css('position', 'fixed').css('top', newTop).addClass(s.className);
s.currentTop = newTop;
}
}
}
},
resizer = function() {
windowHeight = $window.height();
};
// should be more efficient than using $window.scroll(scroller) and $window.resize(resizer):
if (window.addEventListener) {
window.addEventListener('scroll', scroller, false);
window.addEventListener('resize', resizer, false);
} else if (window.attachEvent) {
window.attachEvent('onscroll', scroller);
window.attachEvent('onresize', resizer);
}
$.fn.sticky = function(options) {
var o = $.extend(defaults, options);
return this.each(function() {
var stickyElement = $(this);
if (o.center)
var centerElement = "margin-left:auto;margin-right:auto;";
stickyId = stickyElement.attr('id');
stickyElement
.wrapAll('<div id="' + stickyId + 'StickyWrapper" style="' + centerElement + '"></div>')
.css('width', stickyElement.width());
var elementHeight = stickyElement.outerHeight(),
stickyWrapper = stickyElement.parent();
stickyWrapper
.css('width', stickyElement.outerWidth())
.css('height', elementHeight)
.css('clear', stickyElement.css('clear'));
sticked.push({
topSpacing: o.topSpacing,
bottomSpacing: o.bottomSpacing,
stickyElement: stickyElement,
currentTop: null,
stickyWrapper: stickyWrapper,
elementHeight: elementHeight,
className: o.className
});
});
};
})(jQuery);
/*]]>*/
</script>
<script type='text/javascript'>
$(document).ready(function(){
$("#mblfloater").sticky({topSpacing:0});
});
</script>
Step#3: Creating a Widget “Sticky” in Blogger:
After adding the JavaScript code, you have to search for the name of your widget. Since, we have named it as "My Sticky Gadget". Therefore, in the template coding search for "My Sticky Gadget". To be able to search correctly it is essential that you must use the built-in search box provided by the Blogger template editor.Note: To enable the search box click anywhere in the template editor and press "CTRL+F". Now on finding "My Sticky Gadget" you will able to see a code similar to the the following one.
<b:widget id='HTML32' locked='false' title='My Sticky Gadget' type='HTML'>
<b:includable id='main'>
<!-- only display title if it's non-empty -->
<b:if cond='data:title != ""'>
<h2 class='title'><data:title/></h2>
</b:if>
<div class='widget-content'>
<data:content/>
</div>
</b:includable>
</b:widget>
Now after finding the code as mentioned above, just replace it completely with the following coding.
<b:widget id='HTML32' locked='false' title='My Sticky Gadget' type='HTML'>
<b:includable id='main'>
<div id='mblfloater'>
<!-- only display title if it's non-empty -->
<b:if cond='data:title != ""'>
<h2 class='title'><data:title/></h2>
</b:if>
<div class='widget-content'>
<data:content/>
</div> </div>
</b:includable>
</b:widget>
Remember: The ID of your widget should be unique. For example, if you are using id='HTML32' in any of your widget then you cannot use the same ID for others.
All done: Once everything is done, press the "Save Template" button to finish the process.
Sticky floating sidebar widgets can bring a lot of growth in your sign ups. They help in increasing user engagement. You can also use multiple floating widgets in sidebar. However, this act might annoy your visitors. Make sure you have a balanced design, so that it don't annoy your users
We hope that this article have helped you in creating a Sticky floating sidebar widget in your Blogger website. This plugin is robust enough to be used in any element of your sites. Let us know what you think in the below comments.

yaar faizan intahai talented boy hai.
ReplyDeleteOf course!
Deletecan i use this floating widget on google adsense ads in my blog sidebar..I have seen others using it but i want to know if it is against the Adsense TOS...You are doing a great job here....Thanks
ReplyDeleteWell not exactly, Google has mentioned in there policy that Floating ads are not allowed. But I have seen on my big sites that they are using Adsense Floating ads.
DeleteSo, to keep yourself on the right side don't apply them. Cheers
So what about 9gag? they are also using it
DeleteThey are Premium Adsense Publishers
DeleteAnything you want!
ReplyDeleteHi Syed,
ReplyDeleteUnfortunately ran into a problem...
The sticky widget is working fine but other sidebar widgets are overlapping it when scrolling down. In other words, it is not being shown properly like yours. Please go here to see what I mean:
http://cricketnns.blogspot.com
Thank you very much for all the help! Really appreciate it!
You are using a Defected Template. So can't really help. Try using different themes. May be anyone from Templateism.com
Deletebut how to make the widget gone / dissapear when user reach comment box, email me : aliefrezki555@gmail.com
ReplyDeleteWe will soon release that one. Stay tuned!
DeleteWhy this Floating sticky sidebar don't work with Dazzling theme,
ReplyDeletePlease help me, Thanks before :)
We cannot use two floating items at a time. Dazzling has Floating header so it cannot have Floating Sidebar! Cheers
DeleteThanks for replying, but i still have 1 question..
Deletei already used the template without floating header, is there any
way to solve this problem ?
Thanks before :)
Good idea...compliments!
ReplyDeletei added widget directly in templete but my hellobar and right side 300*600 adsense ad gets over this while scrolling
ReplyDeletei used the widget and it shows up fine on the blog...however when I go to edit it, it says....invalid widget, error 400
ReplyDeleteAny ideas?
Nice Tutorial.. I have one problem.. This floating widget scrolls too much down until it covers the footer..How can I stop the scrolling until a certain point? Please help
ReplyDeleteWe tried hard but Blogger is not robust enough to stop this scrolling
Deletehi Syed, thanks for this widgets, it works great! but, I have 1 query. sometimes the widgets hides behind other widgets.
ReplyDeleteI want to specify
z-index: 100;
in css to bring the widget container in front of other widgets. is there any way to specify this in you java script code. Thanks for this great java script, realty liked it. keep it up!
That might happen because those other widgets might be set to position:absolute; so make sure they are not. Hope that helps!
DeleteCheers!
I have the same problem which Dinesh mentioned on my blog tweaksformypc.com. Could you please explain how can I fix it. I am not a programmer, so step by step instruction is much appreciated. Thank you
Deletethanks for yor reply
DeleteIt worked on some widgets, but some widgets are still hiding behind.
still I want to specify "z-index: 100;" , any idea?
You need to provide lower z-index to those widgets which are overlapping
Deletei fixed it by adding another java script which changes the z-index,, thanks for your help, its see how it is working on my blog brain-of-computer.blogspot(dot)com
DeleteNice Post,,,,
ReplyDeleteHey! I have a problem the widget is transparent is does not overlaps can you suggest?
ReplyDeleteThanks! This is really great!
ReplyDeleteHow do I make my sticky sidebar gadget have a solid background. Right now it's transparent and doesn't look good when it moves over other gadgets.
Thanks!
Can you please provide your BLOG URL?
Deletehttp://liveminimally.blogspot.com/
DeleteIt's started to do this weird thing where it only shows my recent blog list. If this link doesn't take you to the main page just click on any of the links on the list shown and that should take you there.
You'll see 2 different sticky menus. One on the main page and a second conditional one here >>> http://liveminimally.blogspot.com/p/blog-page_25.html
Thanks so much for your help!!
I have made it solid background but the problems is it could not overlap the adsense.
ReplyDeleteThats why i am saying to provide blog url so i can provide you a fix.
DeleteI have the same problem. It is transparent which is not working. Can you tell me the solution. Thank you.
ReplyDeleteCan you please provide more details.?
DeletePlease can you tell me how to float more than 1 widget at same time.I want to float two widget in my blog
ReplyDeletePlzzz