I saw this script but wondering if this is possible using div instead of image
which maintains the ratio whether you adjust browser height or width
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>maintain height and width</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script language="JavaScript" type="text/javascript">
var adjustSize = function(){
var total = 0, // include extra width padding here
win = $(window),
winW = win.width(),
// subtract scroll bar height to prevent vertical scrollbar
winH = win.height() - 15;
$('#container img').each(function(){
var $t = $(this),
r = $t.width()/$t.height(); // image aspect ratio
// set image size, but maintain aspect ratio
worh = (r > 1) ?
{ width : winW, height: winW/r, maxHeight: winH, maxWidth: winH*r } :
{ height : winH, width : winH*r, maxWidth: winW, maxHeight: winW/r };
$t.css(worh);
// add up total width for body size
total += $t.width();
});
$('body').width(total);
};
// run script after all the images have loaded & on window resize
$(window)
.load(function(){ adjustSize(); })
.resize(function(){ adjustSize(); });
</script>
<style type="text/css">
#container img {
float: left;
}
/* pick a width number so that the images load horizontally instead of vertically */
body {
width: 100%;
}
</style>
</head>
<body>
<div id="container">
<img src="http://images2.fanpop.com/image/photos/13700000/Chaplin-charlie-chaplin-13789434-1024-768.jpg" width="820" height="615" /></div>
</body>
</html>