Home » , » The easiest way to Make sticky widget on the blog

The easiest way to Make sticky widget on the blog

Sticky widget This function would make the visitor becomes easier to see Sidebar Widget that you use on your blog, and Sticky Widget does not create a blog so heavy or no effect on the weight of your blog, so do not hesitate to use this Sticky Widget.
  • Sign in to your Blogger Dashboard
  • Click Template »Edit HTML
  • Find the code]]> </ b: skin> (to speed up the search press Ctrl + F)
  • Enter the following code above / before the code]]> </ b: skin>

     <!--sticky-->
    #mdstickybar {background-color:#ECEEF5;padding-top:10px;width:300px!important;padding-bottom:15px;
    color:#474747;}
    <!--sticky-->

Then look for the code </ head> and enter the following code above / before </ head>

<!--sticky--> <script src='//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js'/> <script type='text/javascript'> /*<![CDATA[*/ // Sticky Plugin // ============= // Author: Lintas Weblog // Improvements by German M. Bravo (Kronuz) and Ruud Kamphuis (ruudk) // Created: 2/14/2011 // Date: 9/12/2011 // Website: http://labs.anthonygarand.com/sticky // Description: Makes an element on the page stick on the screen as you scroll // For Blogger by : http://lintasweblog.blogspot.com/ (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> <!--sticky-->

Next find </ body> then Enter the following code above / before </ body>

     <script type='text/javascript'>
    $(document).ready(function(){
    $(&quot;#mdstickybar&quot;).sticky({topSpacing:0});
    });
    </script>

Now save your template .

After that we have to look for ID Widget will we post Sticky widgets, how to search for an ID Widget Simply by going to the Layout »Then search widget will you post Sticky» then click Edit on the Widget, ID Widget buddy will be listed on Url Widget , examples Url Widget:
http://www.blogger.com/rearrange?blogID=1787216510986734973&action=editWidget&sectionId=sidebar-bawah&widgetType=null&widgetId=HTML2

Againt go to edit your template ( edit html ) and then Then look for your Widget ID that was wanted by Sticky WidgetSample ID Widget that of the Template

<b:widget id='HTML2' locked='false' title='Contact' type='HTML'> <b:includable id='main'> <!-- only display title if it's non-empty --> <b:if cond='data:title != &quot;&quot;'> <h2 class='title'><data:title/></h2> </b:if> <div class='widget-content'> <data:content/> </div> <b:include name='quickedit'/> </b:includable> </b:widget>

Above is a native widget code in the default template, may usually differ slightly, but how to create a Sticky Widget will always work :P

then add this code between the code <div id = 'mdstickybar'>
So the result will be like this


<b:widget id='HTML2' locked='false' title='Contact' type='HTML'> <b:includable id='main'> <div id='mdstickybar'> <!-- only display title if it's non-empty --> <b:if cond='data:title != &quot;&quot;'> <h2 class='title'><data:title/></h2> </b:if> <div class='widget-content'> <data:content/> </div> </div> <b:include name='quickedit'/> </b:includable> </b:widget>

Next save template

its all !! thanks for coming !

0 comments:

Post a Comment