<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Easy Vertical Centering To Browser Viewport</title>
<style type="text/css">
html,body{
height:100%;/*reference for v-float height*/
margin:0;
padding:0;
}
body{
background:#FFF;
min-width:800px;
min-height:600px;/*set min-height same as #img-wrap total height*/
}
#v-float{
float:left;
height:50%;
margin-top:-300px;/*half of #img-wrap total height*/
width:100%;
}
#img-wrap {
clear:both;
width:600px;
height:600px;
margin:0 auto;
background:#BBB url(images/img.gif) no-repeat;
overflow:auto;/*establish margin clearance and insure access to content*/
}
h3 {
margin:1em;
text-align:center;
}
</style>
</head>
<body>
<div id="v-float"></div>
<div id="img-wrap">
<h3>The image is set as a background image on this div</h3>
</div>
</body>
</html>
Bookmarks