which gives we much more possibilities than only centering ...
Solution 3:
Here's my go at it. We ended up using it for my Lightbox clone. The main advantage of this solution is that the element will stay centered automatically even if the window is resized making it ideal for this sort of usage.
If we have a div with id "test" to center then the following script would center the div in the window on document ready. (the default values for "my" and "at" in the position options are "center")
Solution 5:
We would like to correct one issue.
Above code won't work in cases when this.height (lets assume that user resizes the screen and content is dynamic) and scrollTop() = 0,
Related Searches to javascript tutorial - Using jQuery to center a DIV on the screen
jquery center div vertically and horizontallyjquery center div horizontallyjquery popup div center screen examplejquery center()jquery center div in viewporthow to set div in center of screen using javascriptjavascript vertically center divhow to dynamically center a divhow to display div in center of screen using jqueryjquery popup div center screen examplejquery center div on screenjquery center div in viewportjquery center()jquery vertical align text in divjquery css vertical alignjquery center cssjavascript tutorialjava scriptjavascriptjavascript arrayjavascript booklearn javascriptjavascript codejavascript editorjavascript classjavascripjavascript debuggerjavascript onlinejavascript examplesjavascript testjavascript documentjavascript sliderwhat is javascriptjavascript form validationjavascript validatorhtml javascriptjavascript alertjavascript eventsjavascript printjavascript domjavascript objectjavascript functionhref javascriptjavascript datejavascript promptjavascript onclickjavascript returnjavascript forjavascript numberjavascript confirmjavascript onchangejavascript regular expressionjavascript ifjavascript variablejavascript timerjavascript cookiejavascript getelementbyidjavascript innerhtmljavascript calljavascript regexpjavascript includesjavascript thisjavascript eval