开发者

Position:relative for anchors in webkit broken. Work-arounds?

In our project we used the following method to link users to some anchorred area on the page:

<span style="position: relative; top: -100px; z-index: -1; visibility: hidden;"
                   id="anchor">&nbsp;</span>

This was used to leave a little space before the exact anchorred element like a form.

Position:relative for anchors in webkit broken. Work-arounds?

But since some late version of Safari this has broken and browser is positioning at the initial position of the element with no regard to the relative position.

Maby you have met this feature/bug too and have some work around to propose or can point out why my method 开发者_如何学编程is bad.


Yep! hanks to the incorrect but usable answer by Developer Art i got the solution!

If i apply id and relative position to the DIV anchoring to the #id starts working with telative scroll!


Why don’t you just add the ID attribute to the element in question, i.e. FORM? If you want to add vertical spacing before the form, you can use CSS:

<form id="anchor" style="margin-top: 100px;">
 …
</form>

Issue eliminated, and much cleaner code :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜