Created
August 23, 2013 14:46
-
-
Save ursuleacv/6320146 to your computer and use it in GitHub Desktop.
Modal pop up window to fit within browser view if resize height
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
$(function(){ | |
$(window).resize(function(){ | |
// get the screen height and width | |
var maskHeight = $(window).height(); | |
var maskWidth = $(window).width(); | |
// calculate the values for center alignment | |
var dialogTop = (maskHeight - $('#dialog-box').height())/2; | |
var dialogLeft = (maskWidth - $('#dialog-box').width())/2; | |
// assign values to the overlay and dialog box | |
$('#dialog-overlay').css({ height:$(document).height(), width:$(document).width() }).show(); | |
$('#dialog-box').css({ top: dialogTop, left: dialogLeft, position:"fixed"}).show(); | |
}).resize(); | |
}); | |
http://jsfiddle.net/tF8TU/2/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment