标签:position 返回顶部 dcl ali :hover top demo 模仿 center
<style> .divH { height: 1800px; } .divT { width: 50px; height: 50px; font-size: 18px; background-color: #2F4F4F; text-align: center; color: white; position: fixed; right: 18px; bottom: 18px; } .divT:hover{ cursor: pointer; } .hide { display: none; } </style> </head> <body> <div class="divH"></div> <div class="divT hide" onclick="ReturnTop();"><strong>返回顶部</strong></div> <script src="./jq/jquery-1.9.1.min.js"></script> <script> window.onscroll = function () { var current = $(window).scrollTop(); if (current > 180){ $(".divT").removeClass("hide"); }else { $(".divT").addClass("hide"); } }; function ReturnTop() { $(window).scrollTop(0); } </script>
网页右下角有个返回顶部按钮,模仿淘宝?window.scrollTop()方法
标签:position 返回顶部 dcl ali :hover top demo 模仿 center
原文地址:https://www.cnblogs.com/renqiaoqiao/p/11568464.html