Reputation: 2898
I have a web page. It has too much height; in that page I have a div in the bottom of the page. I want to display the div in the center portion of the page. It’s appearing in the center of the page at the bottom position as in a way I like , but scrolling is needed. Is it possible to set focus on that div without scrolling?
Upvotes: 0
Views: 3029
Reputation: 2617
This will do your work:
document.getElementById('yourElementId').scrollIntoView();
Upvotes: 0
Reputation: 152
You can put an href like this on top of the page Link to My Div
and put another href href=# name="mydiv" like this with a name called mydiv in the div tag you want to link to.
Upvotes: 0
Reputation: 7215
You can use javascript to accomplish this by writing:
document.getElementById("your_element_id").focus();
Upvotes: 0
Reputation: 187020
Place an anchor tag on top of the div. And add a bit of code in the page load [if it is to be shown when the page loads]
location.href = "#youranchorid";
Upvotes: 1