为什么 V2EX 没有返回顶部的按钮?
資深大佬 : pythonzz 4
建议加一个返回顶部的按钮,当然只是个建议
大佬有話說 (28)
摸鱼党已经很熟练了
你可以给我一张截图作为例子吗?就是你觉得比较好的这样的按钮的实现。
谢谢。
(function() {
‘use strict’;
var parent = document.createElement(‘div’);
var top = document.createElement(‘div’);
top.append(‘Top’)
top.onclick = function() {
window.scrollTo(0, 0)
}
top.className = ‘go-top’
top.style.position = ‘fixed’;
top.style.bottom = ’20px’;
top.style.right = ’20px’;
top.style.cursor = ‘pointer’;
top.style.zIndex = ‘999’;
parent.append(top)
document.body.append(parent);
})();
https://greasyfork.org/zh-CN/scripts/389939-top