2
當我向下滾動後,達到100px後,它會將該類添加到div。然後通過使用CSS我添加top:50px;
如何使用jquery和css在距離大於100時修復滾動div?
當我向下滾動後,達到100px後,它會將該類添加到div。然後通過使用CSS我添加top:50px;
如何使用jquery和css在距離大於100時修復滾動div?
它看起來像你的刪除按鈕可能覆蓋容器,即它是一個Z索引問題。是否將足夠高的z-index添加到.fixed-content幫助中?
.fixed-content {
z-index: 9999;
}
如果沒有,你可以張貼一些周圍的HTML,所以我們可以創建一個小提琴,看看/解決實際問題?
要滾動距離後固定在div是> 100像素:
<div id="header"></div>
<style>
#header {
background-color: #f90;
height: 50px;
left: 0;
position: absolute;
top: 100px;
width: 100%;
}
#header.sticky {
position: fixed;
top: 0;
}
</style>
<script>
function header_sticky() {
var header = document.getElementById('header');
if (window.scrollY >= 100) {
header.className = 'sticky';
} else {
header.className = '';
}
}
window.addEventListener('load', header_sticky, false);
window.addEventListener('scroll', header_sticky, false);
</script>