General offset for all anchors in HTML?

情到浓时终转凉″ 提交于 2019-12-19 06:46:15

问题


I have some anchor elements, but they are in absolute position div and the content of the div is so large that it scrolls inside (overflow:auto).

All entries in the div have an anchor on top, but if I go to this anchor I have the element I wanted to directly on top of the side, but I want it in the center. I need something like an offset so I can jump higher than normal.


回答1:


you could always add another div to wrap around it, and then do something like

.wrapperdiv{
   position:relative;
   top:-10px;
}



回答2:


You could try a Javascript scroll to correct the position.



来源:https://stackoverflow.com/questions/1431639/general-offset-for-all-anchors-in-html

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