移动端的“吸顶”效果
“吸顶”效果是比较常见的一种样式效果。
.fixed {
position: fixed;
top: 0;
left: 0;
bottom: 0;
}
$(window).scroll(function () {
var documentH = $(document).height()
var clientW = $(window).width()
var clientH = $(window).height()
var titleTop = clientW / 750 * 539
var nowTop = $(document).scrollTop()
if (nowTop - titleTop > 0) {
// if (documentH - nowTop - clientH < 3) {
//
//} else {
// $(ele).css({position: 'fixed'})
//}
$(ele).addClass('fixed')
} else {
$(ele).removeClass('fixed')
}
})