我一直在我的网站上使用Material-Design-Lite,我也在使用JQuery来显示一个滚动到顶部的按钮。但他们并没有在一起工作。安装Material-Design-Lite后,该按钮在单击时不起任何作用。
<div class='back-to-top'>
<a class='hvr-icon-spin' href='#'/>
</div>
<script>
$(window).scroll(function() {
if($(this).scrollTop() > 200) {
$('#back-to-top').fadeIn();
} else {
$('#back-to-top').fadeOut();
}
});
$('#back-to-top').hide().click(function() {
$('html, body').animate({scrollTop:0}, 600);
return false;
});
</script>有没有其他方法可以解决这个问题?我试着不使用JQyery,但它也不起作用。我正在尝试使用的网站是here.
发布于 2015-10-12 18:57:47
这可能是由于主容器header的固定位置造成的。材料设计使用mdl容器中的溢出。所以使用下面的代码来滚动顶部:
$(".mdl-layout__content").animate({scrollTop:0}, 500, "slow");发布于 2016-10-31 09:13:04
您可以尝试使用
$('.mdl-layout__content').animate({scrollTop:0}, 'slow');发布于 2015-07-28 13:43:03
您可以使用下面的链接进行检查。
http://jsfiddle.net/6qrQF/88/
jQuery(document).ready(function() {
//set the link
jQuery('#top-link').topLink({
min: 500,
fadeSpeed: 100
});
//smoothscroll
jQuery('#top-link').click(function(r) {
jQuery("html, body").animate({ scrollTop: 0 }, 300);
});
});https://stackoverflow.com/questions/31667811
复制相似问题