views:

83

answers:

1

I'm new to web development, I'm sure there's a simple answer to this, but I cannot figure it out. Not entirely sure how to refer to things. All is done in HTML, Javascript and CSS.

I have an HTML page in which I use divs to define clickable objects in CSS. I'd like to have Page X be able to exist just as a page without always snapping to a point, but I would like to make links on another page that lets the user snap to various areas on the page both vertically and horizontally (Go to point x,y on page). Kind of like with anchoring, but it needs to put the object in the center of the screen rather than simple vertical scrolling I've gotten anchor links to do.

I do not want the object to be permanently centered (What has come up on Google no matter how I try to search for this).

I've tried using HTML anchors to do this, but I can only seem to make them align to the upper right hand corner of the window, not the center.

As I've said, I'm sure this is a simple answer, I just cannot figure it out for the life of me.

Edit: I've gotten this to sort of work passing data through URLs and using the built in scrollTo function, but I can't seem to get the point scrolled to to be on the center of the screen, just in it.

A: 

Try taking a look at the jQuery ScrollTo plugin.

Tobias Cohen
This does do scrolling correctly, but I can't seem to find a way to center the item I'm scrolling to. (And continue to be resolution independent)
Dylan
How about using something like $(window).height() / 2 to adjust for window size.
Tobias Cohen
Got this to work using jQuery ScrollTo and a small addition I got through the comments. Thanks a lot.
Dylan