Created
March 17, 2014 15:37
-
-
Save mtetlow/9601548 to your computer and use it in GitHub Desktop.
bootstrap modal centering and resizing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$j('.modal').on('show.bs.modal', function(e) { | |
var modal = $j(this); | |
var modalContent = $j(this).find('.modal-content'); | |
var modalDialog = $j(this).find('.modal-dialog'); | |
//If the modal is too tall, resize it | |
if($j(modalDialog).height()>=$j(window).height()){ | |
$j(modalDialog).height($j(window).height()-20); | |
} | |
//If the modal is too wide, resize it | |
if($j(modalDialog).width()>=$j(window).width()){ | |
$j(modalDialog).width($j(window).width()-20); | |
} | |
//Vertically center the modal | |
$j(modalDialog).css('margin-top',($j(window).height()-$j(modalDialog).height())/2+'px'); | |
return this; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment