分享一个曾经自用的返回顶部按钮代码,可用于个人主页:
第一步引入JS和CSS文件:
<link rel="stylesheet" type="text/css" media="screen" href="https://www.huawenonline.com/css/top.css" />
css内容:
#returnTop { _display:none; position:fixed; _position:absolute; z-index:999; right:15px; bottom:-200px; _bottom:auto; width:36px; height:65px; text-indent:-999px; overflow:hidden; background-image:url(/img/Top.png); _background-image:url(/img/Top.png); background-repeat:no-repeat; background-position:0 0; transition:bottom 0.9s; -webkit-transition:bottom 0.9s; -moz-transition:bottom 0.9s; -o-transition:bottom 0.9s; } #returnTop:hover { background-position:0 -65px; }
<script type="text/javascript" src="https://www.huawenonline.com/js/top.js"></script>" />