Home » » Tiện ích sticky cho blogspot trên từng widget

Tiện ích sticky cho blogspot trên từng widget

Coppy code sau vào widget html muốn đặt sticky  : 
<style>
#sticky {
 height:600px; /* chiều cao của banner quảng cáo*/
 width:300px; /* độ rộng của banner quảng cáo*/
 position:relative;
}
</style>
<!--stickith2.js file hots .js-->
<script type="text/javascript" src="https://googledrive.com/host/0B_I_CznaRRcIU2ZkQ0UzYmlGZ2s/"></script>
<script>
var $stickyHeight =500; // chiều cao của banner quảng cáo
var $padding =43; // khoảng cách top của banner khi dính
var $topOffset = 1285; // khoảng cách từ top của banner khi bắt đầu dính (tức là khoảng cách tính từ trên xuống đến vị trí đặt banner )
var $footerHeight =0; // Định vị điểm dừng của banner, tính từ chân lên
/* <![CDATA[ */
function scrollSticky(){
 if($(window).height() >= $stickyHeight) {
     var aOffset = $('#sticky').offset();
if($(document).height() - $footerHeight - $padding < $(window).scrollTop() + $stickyHeight) {
         var $top = $(document).height() - $stickyHeight - $footerHeight - $padding - 185;
         $('#sticky').attr('style', 'position:absolute; top:'+$top+'px;');

     }else if($(window).scrollTop() + $padding > $topOffset) {
         $('#sticky').attr('style', 'position:fixed; top:'+$padding+'px;');
}else{
         $('#sticky').attr('style', 'position:relative;');
     }
 }
}
$(window).scroll(function(){
 scrollSticky();
});
/* ]]> */
</script>
<div id="sticky">
Chèn tiện ích ta muốn thêm  vào đây
</div>


Như thế là xong 

0 nhận xét:

Post a Comment

 
Home | Nhà đẹp | Trần Thạch Cao | Đá Granic | Sơn nhà| Rao Vặt | Email| ô tô | Call phone: +84987002345 | ATLĐ | Feed | Youtube | Facebook | Twitter | Google+ | Login | Register |