center element on screen in jQuery
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

jQuery.fn.center = function () {
	this.css('position','absolute');
	this.css('top', ( $(window).height() - this.height() ) / +$(window).scrollTop() + 'px');
	this.css('left', ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + 'px');return this;}
	//Use the above function as: $(element).center();

You may want to check :

  1. make an entire list element (LI) clickable
  2. Absolute Center (Vertical & Horizontal) an Image
  3. Clean way to open popup windows
  4. Do … to an element when it comes into the view by scrolling
  5. center an element on screen

Post a Comment

Your email is never shared. Required fields are marked *

*
*