LLWiki正在建设中,欢迎加入我们!
“Widget:游戏主界面”的版本间差异
跳转到导航
跳转到搜索
小 |
小 |
||
第15行: | 第15行: | ||
clearInterval(timer); |
clearInterval(timer); |
||
timer = setTimeout(function() { |
timer = setTimeout(function() { |
||
if(eleStatic.getBoundingClientRect().top < eleFixed. |
if(eleStatic.getBoundingClientRect().top < eleFixed.getBoundingClientRect().top) { |
||
eleFixed.style.display = 'none'; |
eleFixed.style.display = 'none'; |
||
eleStatic.style.visibility = ''; |
eleStatic.style.visibility = ''; |
2020年10月6日 (二) 00:09的版本
JavaScript脚本:
window.addEventListener('load', function () {
var eleStatic = document.querySelector('.start-screen');
eleStatic.querySelectorAll('a').forEach(function(ele) {
ele.href = 'javascript:void(0)';
});
var eleFixed = eleStatic.cloneNode(true);
eleFixed.classList.add('sticky-bottom');
eleStatic.parentNode.insertBefore(eleFixed, eleStatic);
eleFixed.style.width = eleStatic.getBoundingClientRect().width + 'px';
eleStatic.style.visibility = 'hidden';
var timer = -1;
window.addEventListener('scroll', function() {
clearInterval(timer);
timer = setTimeout(function() {
if(eleStatic.getBoundingClientRect().top < eleFixed.getBoundingClientRect().top) {
eleFixed.style.display = 'none';
eleStatic.style.visibility = '';
}
else {
eleFixed.style.display = '';
eleStatic.style.visibility = 'hidden';
}
}, 400);
});
});
//
CSS样式表:
*/
.start-screen {
text-align: center;
}
.start-screen table {
display: inline-table;
}
.sticky-bottom {
position: fixed;
bottom: 3px;
}
/*