LLWiki正在建設中,歡迎加入我們!
「Widget:游戏主界面」修訂間的差異
跳至導覽
跳至搜尋
小 |
小 |
||
第9行: | 第9行: | ||
eleFixed.classList.add('sticky-bottom'); |
eleFixed.classList.add('sticky-bottom'); |
||
eleStatic.parentNode.insertBefore(eleFixed, eleStatic); |
eleStatic.parentNode.insertBefore(eleFixed, eleStatic); |
||
eleFixed.style.width = eleStatic.getBoundingClientRect().width; |
eleFixed.style.width = eleStatic.getBoundingClientRect().width + 'px'; |
||
eleStatic.style.visibility = 'hidden'; |
eleStatic.style.visibility = 'hidden'; |
||
window.addEventListener('scroll', function() { |
window.addEventListener('scroll', function() { |
於 2020年10月5日 (一) 23:37 的修訂
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';
window.addEventListener('scroll', function() {
if(eleStatic.offsetTop < eleFixed.offsetTop) {
eleFixed.style.display = 'none';
eleStatic.style.visibility = '';
}
else {
eleFixed.style.display = '';
eleStatic.style.visibility = 'hidden';
}
});
});
//
CSS樣式表:
*/
.start-screen {
text-align: center;
}
.start-screen table {
display: inline-table;
}
.sticky-bottom {
position: fixed;
bottom: 3px;
}
/*