Demo:
Cho code sau vào cuối Footer
Tạo 1 Js
In all page
Css:
Cho code sau vào cuối Footer
- Code:
<a style="right: 0px;" href="#" id="go_top">LÊN ĐẦU TRANG</a>
Tạo 1 Js
In all page
- Code:
$(function(){$('body').append('<div id="loading" style="background-color: #2E3539;-webkit-background-clip: padding-box;background-clip: padding-box;left: 0;right: 0;top: 0px;padding: 8px 0;position: fixed;text-align: center;z-index: 99999;background-position: initial initial;background-repeat: initial initial;opacity: .9;"><center><img src="http://metro.eazy.vn/styles/eazy_metro/theme/images/13x13progress.gif"></center></div>');$(window).load(function(){$('#loading').fadeOut(2000,function(){$(this).remove})})});(function(){$('.go_top').click(function(){$('body,html').animate({scrollTop:0},400);return false})})(jQuery);(function(){$(window).scroll(function(){if($(window).scrollTop()==0){$('#go_top').stop().animate({right:-130},300)}else{$('#go_top').stop().animate({right:0},300)}});$('#go_top').click(function(){$('body,html').animate({scrollTop:0},400);return false})})(jQuery);
Css:
- Code:
#go_top{background-color:#E52A49;bottom:30px;color:#FFF;display:block;opacity:.3;padding:5px 10px;position:fixed;right:-130px;text-decoration:none}
#go_top:hover{opacity:1}
#go_top{-moz-transition:all .3s ease 0;-ms-transition:all .3s ease 0;-o-transition:all .3s ease 0;-webkit-transition:all .3s ease 0;transition:all .3s ease 0}