Top section is the navigation. Always the same height.
An image scaling proportionally, always filling the remaining height of the browser.
All other content under the ‘fold’.
You can create a scaling background image by setting the width to 100% and leaving the height to find its own level.
I know you said you wanted the height of the browser to be the scaling factor, but if you try to do it that way you won’t have any room beneath for your content as the browser is always full.
The following script loads a very large image to fill the browser viewport while maintaining a fixed width navigation bar at the top of the page. You can see it all working in this jsfiddle
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title>vlarge pic</title>
<script type="text/javascript">
</script>
<style type="text/css">
body { font-family:arial, helvetica, sans-serif; font-weight:normal; font-size:13px; color:#000; text-align:left; margin:3px 0px; }
#imgWrap { z-index:1; position:absolute; top:0px; left:0px; width:100%; height:100%; }
#navBoxFrm { z-index:10; position:relative; top:0px; left:0px; padding:20px; }
#navBox { width:800px; height:60px; margin:0px auto; background-color:#CCC; }
#textBlk { width:800px; margin:0px auto; }
.a24px { font-size:24px; color:#000; font-weight:bold; text-align:center; }
</style>
</head>
<body>
<div id="navBoxFrm">
<div id="navBox" class="a24px">
Navigation Here</div>
</div>
<div id="imgWrap">
<img border="0" src="http://www.allanp.net/AA/cityscape.jpg" width="100%">
<div id="textBlk">
<p>Magnus es, domine, et laudabilis valde: magna virtus tua, et sapientiae tuae
non est numerus. et laudare te vult homo, aliqua portio creaturae tuae, et homo
circumferens mortalitem suam, circumferens</p>
<p>testimonium peccati sui et testimonium, quia superbis resistis: et tamen
laudare te vult homo, aliqua portio creaturae tuae.tu excitas, ut laudare te
delectet, quia fecisti nos ad te et inquietum est cor nostrum, donec requiescat
in te. da mihi, domine, scire et intellegere, utrum sit prius invocare te an
laudare te, et scire te prius sit an invocare te. sed quis te invocat nesciens
te? aliud enim</p>
</div>
</div>
</div>
</body>
</html>
Apologies. This is not a live site. It’s a page I will build this week. I’m trying to find a way to conceptually create solve this layout behaviour before I move on.
Yes, but what I’m looking for is the opposite. The background image should always fill the height (minus the absolute set height of the nav section), and leave the width to find it’s own. I tried to illustrate the best I could.
Only when the page loads. I should have mentioned that.
You can do something like this for IE9+ (without js) and uses the display table properties and background-size to achieve the effect.
The content will always below the fold which seems to be what you wanted. The background-size:cover will ensure the image maintains its aspect ratio rather than just get squashed.
Thanks Paul. I need A grade browser support, so I might have exhausted my CSS only options here. It looks like I need the help of JS to get this the right way. The Y axis of the image should always display.
Yes, I’ve played around with it a little bit but it doesn’t really do anything more than I can do already by other means (apart from when used in nested elements and then the concept isn’t that useful apart from a few odd cases).