问题描述
在我的情况下,当我单击About的子菜单(同一页面的子菜单#link)时,我的About页面的视差在每个部分都移动良好.但是在我的网站首页中,如果有人先单击子菜单,则转到相同的子菜单,然后转到确切位置.我几乎完成了.但是offset().top没有给我确切的值.所以我卡住了.
in my case, my about page is parallax moving well every section when i'm click on about's sub menu (submenu for same page #link). but in my site home page has the same submenu if somebody click on the submenu first goto about page then the exact position. I make it almost done. but offset().top not giving me the exact value. so I stuck.
我准备好在准备好文档时控制台查看offset.top值.
I console to see offset.top value when document ready..
帮助我了解为什么会发生这种情况???
help me to understand why this happen???
先谢谢了.对不起,英语不好
thanks in advance.sorry for poor english
我的网站在这里 http://doitte.com/delatest/
推荐答案
这是因为在准备就绪的文档中,某些内容可能尚未达到其高度.这可能是由于资源,例如图像,字体,延迟的css/js加载等.
this is because on document ready some of the content may have not got their height. This could be due to resources such as images, font-faces, delayed css/js loading etc.
代替$(document).ready();
代替$(window).load();
这篇关于文件就绪和console.log()中的offset.top值为何不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!