Forum Moderators: not2easy

Message Too Old, No Replies

C Frame 100% screen no matter screen resolution

This will show you how to make a 100% height and 100% application window

         

Caspan

12:19 am on Aug 6, 2007 (gmt 0)

10+ Year Member



I wanted to post this as i have spent over 1 week trying to do the following:
I wanted to make my application for the web act just like a MS Windows application would I.E. header across the top, menu on the side, scrollable content area in the middle and footer on the bottom. and jsut liek a real application the header footer and menu woud be static but the content are would resize. I wont tell you all the reason why you shouldent use tables and why you should use div' but i decided for a 100% div layout for my site (yes i tried tables and failed to get this to work) I have finally found the solution please copy paste my code below to get a C frame template with scrolling content area, my code is free for the taking jsut let me know if it works for you i have tried this only on IE7 and FF2.0 as there are the most recent browsers.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "//www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>C Frame Porthole</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">

<style type="text/css">
* {margin: 0; padding: 0;}
html, body {width: 100%; height: 100%; overflow: hidden;}
#header-div {position: absolute; top: 0px; height: 40px; left:0px; right: 0px; border: 1px solid #000;}
#body-div {position: absolute; top: 40px; bottom: 30px; left: 0; right: 0;}
#body-menu-div {position: absolute; top: 0px; bottom: 0px; left: 0; width: 200px; border: 1px solid #000;}
#body-content-div {position: absolute; top: 0px; bottom: 0px; right: 0; left: 201px; border: 1px solid #000; overflow: auto;}
#footer-div {position: absolute; bottom: 0px; height: 29px; left:0px; right: 0px; border: 1px solid #000;}
</style>
</head>

<body>
<div id="header-div">This is the header container</div>
<div id="body-div">
<div id="body-menu-div">This is the navagation container</div>
<div id="body-content-div">
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
content for scrolling div<br>
</div>
</div>
<div id="footer-div">This is the footer container</div>
</body>
</html>

londrum

8:22 pm on Aug 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



it's always nice when something finally works

(it tried it in Opera, and Safari for windows for you, and it works in those too)

Robin_reala

9:20 pm on Aug 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yep, I'm using something similar on a current project. For what it's worth I don't believe setting all four of t/b/l/r for positioned objects works in IE5 or 6 so this might not be applicable for the wider web at the moment (although having said that I think we'll probably be dropping IE5 next month).

Xapti

12:47 am on Aug 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yeah, the page is very broken in IE6... partly if not solely due to it's non support of simultanious use of left with right, and top with bottom. Javascript can fix this.

And is there a reason for the #body-div? content div and menu div can still be positioned properly without it, making it unnecessary nesting.

[edited by: Xapti at 12:51 am (utc) on Aug. 7, 2007]

Xapti

5:09 am on Aug 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Another method, granted very lousy, but does not use absolute positioning at all (and so works in IE6)is something like this...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>title of page</title>
<meta http-equiv="content-type" content="text-html; charset=utf-8">
<style type="text/css">
*{padding:0;margin:0}
body, html{height:100%}
#header{height:100px;background-color:blue;position:relative;}
.spacer{height:100px;}
#big{height:100%;background-color:pink;margin-bottom:-100px;overflow:auto}
#footer{height:100px;background-color:red;position:relative;margin-right:16px}
</style>
</head>
<body>
<div id="big">
<div id="header">header</div>
<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<div class="spacer"></div>
</div>
<div id="footer">footer</div>
</body>
</html>
There are visible problems though in both the code and display. Not sure if there's improvements that can be made on it. For the side menu (not included), you would have to use faux columns.

The easiest way though, would of course be to just use percentage heights to total 100. The only downside is that when the window is small enough the header/footer content will scroll or overflow; and when the window is too big, there will be a bit of wasted space taken up by the header and footer.