我在这个网站上安装了网站。
每次我点击一个缩略图启动灯箱,背景中的身体内容会稍微向下滚动。有什么办法能阻止这种事发生吗?
我感觉到lightbox脚本在某种程度上干扰了我的滚动到顶部代码:
// Magnific Popup open inline content
$('.open-popup-link').magnificPopup({
type:'inline',
midClick: true
});
// Magnific Popup open iframe content
$('.vimeolink').magnificPopup({
type: 'iframe',
});
// Smooth scrolling - https://css-tricks.com/snippets/jquery/smooth-scrolling/
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
// Scroll to top - http://www.paulund.co.uk/how-to-create-an-animated-scroll-to-top-with-jquery
$(window).scroll(function(){
if ($(this).scrollTop() > 100) {
$('.scrollToTop').fadeIn();
} else {
$('.scrollToTop').fadeOut();
}
});
// Click event to scroll to top
$('.scrollToTop').click(function(){
$('html, body').animate({scrollTop : 0},800);
return false;
});发布于 2015-03-06 13:06:30
$('a[href*=#]:not([href=#]')与单击的图像相匹配,例如<a class="open-popup-link" href="#popup-183">。所以是的,当你点击一个图片,不仅弹出,而且页面滚动到哈希在网址,在这种情况下,a#projects。
例如,可以通过添加类来区分锚点的<a>和图像的<a>:
<a class="scroller" href="#whatever"></a>
<a class="open-popup-link" href="#popup-183">现在用他们的类来瞄准他们:
$('a.scroller').click(function() { /* scrolling stuff */ }发布于 2015-08-13 15:13:04
您也可以尝试使用羽光。这个插件不使用链接中的href属性来显示内容,所以您不会遇到这个问题。它也更容易使用,它们的文档也更好(IMO)。
https://stackoverflow.com/questions/28898633
复制相似问题