Scroll to anchor with fixed header, content hidden behind header, margin and top padding not working

爱⌒轻易说出口 提交于 2019-11-27 15:06:35

问题


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%;).


回答1:


SOLVED: http://nicolasgallagher.com/jump-links-and-viewport-positioning/demo/#method-D

There are several methods available.




回答2:


I used Local Scroll (JQuery) to do this.

It allows you to do a top offset

$.localScroll({
    offset: -100
});



回答3:


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.



来源:https://stackoverflow.com/questions/4835885/scroll-to-anchor-with-fixed-header-content-hidden-behind-header-margin-and-top

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!