我发现了一个简单的方法,无需 Java,只需 CSS 和 HTML。
-
将以下内容放在
<after header>中:<a name="top"></a> <a class="to-top" href="#top" title="返回顶部">^</a> -
然后添加一点精致的 CSS:
.to-top { z-index:3; position: fixed; left: 2%; bottom: 5%; padding: 10px; line-height: 12px; font-size:18px; color:black; border:solid 1px black; border-radius:10px; -webkit-animation: float 1s infinite alternate; animation: float 1s infinite alternate; } .to-top:hover{ color:white; background:black; } @keyframes float { 0% { transform: translateY(10px); } 100% { transform: translateY(30px); } } @-webkit-keyframes float { 0% { transform: translateY(10px); } 100% { transform: translateY(30px); } }
这样你就会得到一个漂亮又吸引人的“返回顶部”按钮:![]()
(它会移动哦 ^^!点击这里查看实际效果:forum.fususu.com/t/topic/21/last)
