Lightbox 和 smoothscroll 跳转
Lightbox and smoothscroll jumps
我对这个网站有几个问题:http://niclamarino.altervista.org/Layouts/Beeline/5.html
- 每当您单击“菜单”链接时,屏幕 "jumps" 显示 0.2 秒的屏幕,然后正常工作。
- 在灯箱部分(字符部分),向下滚动到页面底部后灯箱打开。
如何解决这些问题?我根本不是 jquery 程序员!谢谢!
你的问题
这一行 $('a[href*="#"]:not([href="#"])').click(function() {
使网站滚动。它基本上说要在所有 href 开头带有 # 的标签中生效。
所以如果你想限制这种影响添加#menu $('#menu a[href*="#"]:not([href="#"])').click(function() {
wich 是 thw div 包装你的菜单的 id 所以它只影响 link 里面 div
您的菜单平滑滚动脚本仍然存在问题,您应该在 google
中寻找另一个
我注意到并可能导致其他问题的其他事项
您正在加载 2 个不同版本的 jQuery。删除一个。如果你保持 jQuery 2x 这里是 smoothscroll
的片段
$('#menu a[href*="#"]:not([href="#"])').on('click',function (e) {
e.preventDefault();
var target = this.hash;
$target = $(target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top
}, 800, 'swing');
});
将您的脚本放在最后,在关闭 body 之前或在关闭 head
之前
您没有 head 的结束标记,body 也没有 html
Css 应该是外部的
我对这个网站有几个问题:http://niclamarino.altervista.org/Layouts/Beeline/5.html
- 每当您单击“菜单”链接时,屏幕 "jumps" 显示 0.2 秒的屏幕,然后正常工作。
- 在灯箱部分(字符部分),向下滚动到页面底部后灯箱打开。
如何解决这些问题?我根本不是 jquery 程序员!谢谢!
你的问题
这一行 $('a[href*="#"]:not([href="#"])').click(function() {
使网站滚动。它基本上说要在所有 href 开头带有 # 的标签中生效。
所以如果你想限制这种影响添加#menu $('#menu a[href*="#"]:not([href="#"])').click(function() {
wich 是 thw div 包装你的菜单的 id 所以它只影响 link 里面 div
您的菜单平滑滚动脚本仍然存在问题,您应该在 google
中寻找另一个我注意到并可能导致其他问题的其他事项
您正在加载 2 个不同版本的 jQuery。删除一个。如果你保持 jQuery 2x 这里是 smoothscroll
$('#menu a[href*="#"]:not([href="#"])').on('click',function (e) {
e.preventDefault();
var target = this.hash;
$target = $(target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top
}, 800, 'swing');
});
将您的脚本放在最后,在关闭 body 之前或在关闭 head
之前您没有 head 的结束标记,body 也没有 html
Css 应该是外部的