Centrer une div horizontalement et verticalement avec jQuery


/ Published in: jQuery
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $(window).resize(function(){
  2.  
  3. $('.className').css({
  4. position:'absolute',
  5. left: ($(window).width() - $('.className').outerWidth())/2,
  6. top: ($(window).height() - $('.className').outerHeight())/2
  7. });
  8.  
  9. });
  10.  
  11. // To initially run the function:
  12. $(window).resize();

URL: http://tutorialzine.com/2010/03/centering-div-vertically-and-horizontally/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.