Posted By

dottDesign on 06/26/10


Tagged

div css javascript textmate html


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

d55beck


Center div with JQuery


 / Published in: Other
 

  1. <script type="text/javascript">
  2. $(document).ready(function(){
  3.  
  4. $(window).resize(function(){
  5.  
  6. $('.className').css({
  7. position:'absolute',
  8. left: ($(window).width() - $('.className').outerWidth())/2,
  9. top: ($(window).height() - $('.className').outerHeight())/2
  10. });
  11.  
  12. });
  13. // To initially run the function:
  14. $(window).resize();
  15.  
  16. });
  17. </script>
  18.  

Report this snippet  

You need to login to post a comment.