admin管理员组文章数量:1393920
I'm using smoothscroll.js to navigate my site. It stops on the correct anchor in Firefox, however in Chrome it passes the point on the first click of the link, and pushes the content to the top, hiding the content behind the page. then if you click it again, it aligns correctly. I've seen the problems on other sites as well. Curious to see if others have the same problem. Chrome seems to ignore any top padding or margin or positioning (example: top:20%;).
I'm using smoothscroll.js to navigate my site. It stops on the correct anchor in Firefox, however in Chrome it passes the point on the first click of the link, and pushes the content to the top, hiding the content behind the page. then if you click it again, it aligns correctly. I've seen the problems on other sites as well. Curious to see if others have the same problem. Chrome seems to ignore any top padding or margin or positioning (example: top:20%;).
Share Improve this question edited Feb 8, 2011 at 4:06 Commandrea asked Jan 29, 2011 at 8:27 CommandreaCommandrea 5613 gold badges10 silver badges24 bronze badges3 Answers
Reset to default 3I find this solution very easy and useful. You just need to add 1 line of CSS.
html {
scroll-padding-top: 70px; /* height of sticky header, because the header hides the content when jumping to it */
}
original answer: https://stackoverflow./a/56467997
I used Local Scroll (JQuery) to do this.
It allows you to do a top offset
$.localScroll({
offset: -100
});
This may be due to a new wordpress theme using the header html5 element. I changed my header to a div, and it worked fine.
本文标签:
版权声明:本文标题:javascript - Scroll to anchor with fixed header, content hidden behind header, margin and top padding not working - Stack Overfl 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744083072a2588012.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论