How do I center the browser viewport on an element position?
I can find several examples on achieving the opposite but nothing on centering the screen on an element.
EDIT: I am talking about vertically centering the screen against an element.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here’s an example that will vertically center the window on the div you click on: http://jsfiddle.net/BcY7B/
I’m not sure if this totally solves what you’re looking for. Please be aware that there isn’t any way to center the window on a div that is too high up or far down to be centered vertically (because the page ends, so it can’t scroll further to center it). You could get around this by modifying the height of the page the necessary amount, but I highly doubt that will give you the effect you’re looking for.