Here's a starting point (with cross-browser support added for Firefox and Opera): JSFiddle Demo
HTML
<div class="square"></div>
CSS
html, body {
margin: 0;
height: 100%;
}
.square {
width: 300px;
height: 300px;
margin: 0 auto;
background-color: #7ad;
-moz-transform-origin: center top;
-o-transform-origin: center top;
}
jQuery
function zoomSquare() {
var $square = $('.square');
var viewportHeight = $(window).height();
var squareHeight = $square.height();
var desiredHeight = Math.round(viewportHeight * 0.95);
var zoom = (desiredHeight / squareHeight);
$square.css('zoom', zoom);
$square.css('-moz-transform', 'scale(' + zoom + ')');
$square.css( '-o-transform', 'scale(' + zoom + ')');
}
// When the browser is resized
$(window).on('resize', function(){ zoomSquare(); });
// When the page first loads
$(document).ready(function(){
zoomSquare();
});
Update:
The above code zooms the square element, rather than the entire page. If the entire page needs to be zoomed (which may be the case if there's other content on the page outside of the square), try this second JSFiddle Demo.
When zooming the entire page, I found that zooming in causes horizontal scroll bars to appear in all browsers, which is very bad for usability. To avoid this, zoom out on small browser windows but do not zoom in on large ones. This is how the second Demo behaves (it will only zoom when the browser is very small).