DIV center is not workin
DIV center is not workin
Dear All
http://stackoverflow.com/questions/210717/using-jquery-to-center-a-div-on-the-screen
I am using following code from above web page
(function($){
$.fn.extend({
center: function () {
return this.each(function() {
var top = ($(window).height() - $(this).outerHeight()) / 2;
var left = ($(window).width() - $(this).outerWidth()) / 2;
$(this).css({position:'absolute', margin:0, top: (top > 0 ? top : 0)+'px', left: (left > 0 ? left : 0)+'px'});
});
}
});
})(jQuery);
$('#imagedisplay').center();
$('#imagedisplay').show(1000); /* Not displayed */
$(window).resize(function(){
$('#imagedisplay').center();
});
when i use code as follow
$('#imagedisplay').center();
$('#imagedisplay').show(1000); /* Not displayed */
The DIV is not displayed
where as when I use
$('#imagedisplay').show(1000); /* displayed */
$('#imagedisplay').center();
The DIV with id "
imagedisplay" is displayed (though not centered)
pls help me to use thsi code so as to centralise the DIV
refer Web
http://prajaktasoftware.com/sugandhi/aboutus.php
click on scrolling image
Topic Participants
vikas
jakecigar