I have a page where the content of various AJAXed elements in the main structure. The structure itself is quite simple, and the elements do not have special positioning for them:
<body> <article id="one"></article> <article id="two"></article> <article id="three"></article> </body>
The content of each article is loaded via AJAX calls, and the length of the content for each of them is not known in advance. In addition, you can go to each section with URLs (so I can get to #two using mysite.com/two , it loads the page and scrolls it to the required article).
This works fine, of course, after loading the content, but my problem is that the content before the target element has not yet been loaded. Since the elements must expand to fit the content, it pushes the target element, so instead:
____________________ | Target Element | | | |__________________| | Next Element | |__________________|
You will get the following:
_____________________ | Previous Element | | | | | |___________________| | Target Element | |___________________|
I tried to set a minimum height for content blocks, but this only works part of the time and really only works if the final height is close to the original height.
Ideally, I would like the viewport to remain in the same position with respect to the content, even if the user scrolls before all the content has loaded, but I agree to keep it in position before the user tries to scroll.
Is there any way to do this?