Center DIV via jQuery
- by tony noriega
I have a footer that is fixed to the bottom of the viewport. I am using jQuery toggle to open a comment card for users to comment and submit:
$('a#footer-comment').click(function() {
$("#comment-card").toggle(300);
return false;
$('#comment-card').show({ position:);
});
$('a#footer-comment-hide').click(function() {
$("#comment-card").toggle(300);
return false;
$('#comment-card').hide();
});
naturally if i dont add any CSS selectors to #comment-card it shows up UNDER the footer, and out of sight.
So i added: {position:absolute; bottom:30px; left:auto;} 30px so it shows up above the footer which is 30px high.
Problem is, i can not get this to center in the viewport... if i use pixels, depending on the resolution, it is either too far left or right... how do i center this in the viewport?