topics

全部话题 - 话题: scrolltop
(共0页)
r****y
发帖数: 26819
1
来自主题: Programming版 - HTML5: The future of the Web is finally here
喔,原来是这个意思。
那么探测一个item是不是可见,不需要计算它上面的元素高度,只需要计算$(element)
.offset().top是否大于窗口的scrollTop(),并且该值加上元素本身高度是否小于窗口
的scrollTop()加上窗口高度。
不需要管每个元素是否一样高。
r****y
发帖数: 26819
2
来自主题: Programming版 - HTML5: The future of the Web is finally here
用jquery的offset()和scrollTop(),不用计算高度。一行代码就能确定
scrollposition,还可以animate。

★ 发自iPhone App: ChineseWeb 7.7
l**********n
发帖数: 8443
3
来自主题: Programming版 - 怎样设计动态显示
// jQuery for page scrolling feature - requires jQuery Easing plugin
$(function() {
$('a.page-scroll').bind('click', function(event) {
var $anchor = $(this);
$('html, body').stop().animate({
scrollTop: $($anchor.attr('href')).offset().top
}, 1500, 'easeInOutExpo');
event.preventDefault();
});
});
See:
http://startbootstrap.com/template-overviews/scrolling-nav/
(共0页)