Posted By

Ethyde on 08/30/10


Tagged


Versions (?)

Centrer une div horizontalement et verticalement avec jQuery


 / Published in: jQuery
 

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

  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();

Report this snippet  

You need to login to post a comment.