<div id="toTop" class="hidden-xs" style="display: none;">返回顶部</div>
<style> #toTop {position: fixed;right: 20px;bottom: 25px;zindex: 12;display: none;width: 47px;height: 47px;background:red;text-align: center;text-indent: -9999px;cursor: pointer;} </style>
<script> $(window).scroll(function() { if ($(this).scrollTop() != 0) { $("#toTop").fadeIn() } else { $("#toTop").fadeOut() } }); $("#toTop").click(function() { $("body,html").animate({ scrollTop: 0 }, 800) }) </script>