David Mcmenemy
David Mcmenemy

Reputation: 1

Why does this element appear to scroll when it has position fixed?

I have been trying to figure this out for a while,

I have a page with an element that has a position:fixed; It is positioned to top:0; and left:0; but when you scroll the page, it appears to scroll and dosent remain in the fixed position. If you use the "inspect element" feature on Safari or Chrome it highlights the element as if it is still in the fixed position.

I had originally thought it may be something to do with the fact that the page uses ajax to load content from a database and then uses an infinite scroll to keep loading content as you scroll.

You can view the page at: http://www.davidmcmenemy.com/bwg_shop/index.php

Any help would be great!

Thank you, David

Upvotes: 0

Views: 271

Answers (1)

pedak
pedak

Reputation: 91

Your assumption about ajax is right:

Your question is maybe a duplicate of: Position Fixed in Chrome

Answer: chrome considers that the viewport of an element added to the DOM after the page is loaded (for instance, using jQuery.load()) is restricted to the containing div of this element. Quote: https://stackoverflow.com/a/10849618

Try loading your site without javascript and the navigation will keep its position.

@Oleg Mikheev: Behaviour only occurs in Safari and Chrome. (should be a comment)

Upvotes: 1

Related Questions