The following code for page layout, except for the globaliner iner and dynamiccontent parts, is fixed in size.
Globalcontainer has an initial value of 774px and is automatically adjusted based on the resolution and display of IE menus. Dynamiccontent is dynamically calculated to ensure that footer is always at the bottom.
<! Doctype Html Public "-// W3C // dtd html 4.0 transitional // en">
<HTML>
<Head>
<Title> </title>
<Style Type = "text/CSS">
Body
{
Padding: 0px;
Margin: 0px;
}
# Globalcontainer
{
Width: 100%;
Height: 774px;
Padding: 0px;
Margin: 0px;
}
# Maincontent
{
Min-width: 1280px;
Height: 100%;
}
# Head1
{
Width: 100%;
Height: 100px;
Background-color: Gray;
}
# Head2
{
Width: 100%;
Height: 100px;
Background-color: Aqua;
}
# Footer
{
Width: 100%;
Height: 100px;
Background-color: Silver;
}
</Style>
<Script Type = "text/JavaScript" src = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.3.min.js"> </SCRIPT>
</Head>
<Body>
<Div Id = "globalcontainer" class = "globalcontainer">
<Div Id = "maincontent">
<Div Id = "head1">
This is head1
</Div>
<Div Id = "head2">
This is head2
</Div>
<Div Id = "dynamiccontent">
This is dynamic content
</Div>
<Div Id = "footer">
This is footer.
</Div>
</Div>
</Div>
<Script Type = "text/JavaScript">
// Set footer location
$ (Function (){
Setfooterposition ();
});
$ (Window). Resize (function (){
Setfooterposition ();
});
Function setfooterposition (){
$ (". Globalcontainer" ).css ("height", document. Body. scrollheight-5 );
VaR mainareaheight = $ ("# maincontent"). Height ();
VaR headerheight = $ ("# head1"). Height ();
VaR header2height = $ ("# head2"). Height ();
VaR containerheight = $ ("# dynamiccontent"). Height ();
VaR footerheight = $ ("# footer"). Height ();
VaR innerheight = headerheight + header2height + containerheight + footerheight;
VaR outerheight = headerheight + header2height + footerheight;
If (mainareaheight> = innerheight ){
$ ("# Dynamiccontent"). Height (mainareaheight-outerheight );
}
Else {
$ ("# Dynamiccontent"). Height ("Auto ");
}
}
</SCRIPT>
</Body>
</Html>
|
This layout ensures that footer is always at the bottom and mainly handles the following situations:
1. The page content is very short.
2. The page content is very long.
3. The page is not maximized.
4. From maximization to non-maximization,
5. The page changes from non-maximized to maximized