· 流体布局
<!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>
<title>Liquid layout</title>
<style type="text/css">
#wrapper
{
border: solid 1px blue;
/* width: 720px;*/
width:85%;
margin: 0 auto;
}
#content
{
float: right;
/* width: 520px;*/
width:75%;
border: solid 1px red;
margin-right: 1px;
}
#mainContent
{
float: left;
/*width: 320px;*/
width:66%;
border: solid 1px red;
}
#secondaryContent
{
float: right;
/* width: 180px;*/
width:31%; /* 与mainNav div 一样宽*/
border: solid 1px green;
}
#mainNav
{
float: left;
/*width: 180px;*/
width:23%;
padding-top: 20px;
padding-bottom: 20px;
border: solid 1px black;
margin-left: 1px;
}
#footer
{
border: solid 1px yellow;
clear: both;
}
#footer p
{
text-align: center;
font-weight: bold;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="branding">
<h1 style="text-align: center; border-bottom: solid 1px black">
Liquid layout</h1>
</div>
<div id="content">
<div id="mainContent">
Your application's run-time performance-its speed-is one of its most visible and
critical characteristics. Developing high-performance software that meets the expectations
Your application's run-time performance-its speed-is one of its most visible and
critical characteristics. Developing high-performance software that meets the expectations
</div>
<div id="secondaryContent">
Your application's run-time performance-its speed-is one of its most visible and
critical characteristics. Developing high-performance software that meets the expectations
Your application's run-time performance-its speed-is one of its most visible and
critical characteristics. Developing high-performance software that meets the expectations
</div>
</div>
<div id="mainNav">
<ul>
<li><a href="#">Menu1</a>
<ul>
<li>Sub1</li>
<li>Sub2</li>
<li>Sub3</li>
</ul>
</li>
<li>Menu2</li>
<li>Menu3</li>
</ul>
</div>
<div id="footer">
<p>
Footer Text</p>
</div>
</div>
</body>
</html>
刚性布局:
<!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>
<title>Elastic layout</title>
<style type="text/css">
/*
the default font size on most browsers is 16px
1em roughly equals 10px
*/
body
{
font-size:62.5%;/*1em, 10/16~=62.5%*/
}
#wrapper
{
border: solid 1px blue;
width: 72em;
/* width:720px;*/
margin: 0 auto;
}
#content
{
float: right;
width: 52em;
/* width:520px;*/
border: solid 1px red;
margin-right: 1px;
}
#mainContent
{
float: left;
width: 32em;
/*width:320px;*/
border: solid 1px red;
}
#secondaryContent
{
float: right;
width: 18em;
/* width:180px;*/
border: solid 1px green;
}
#mainNav
{
float: left;
width: 18em;
/* width:180px;*/
padding-top: 20px;
padding-bottom: 20px;
border: solid 1px black;
margin-left: 1px;
}
#footer
{
border: solid 1px yellow;
clear: both;
}
#footer p
{
text-align: center;
font-weight: bold;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="branding">
<h1 style="text-align: center; border-bottom: solid 1px black">
Liquid layout</h1>
</div>
<div id="content">
<div id="mainContent">
Your application's run-time performance-its speed-is one of its most visible and
critical characteristics. Developing high-performance software that meets the expectations
Your application's run-time performance-its speed-is one of its most visible and
critical characteristics. Developing high-performance software that meets the expectations
</div>
<div id="secondaryContent">
Your application's run-time performance-its speed-is one of its most visible and
critical characteristics. Developing high-performance software that meets the expectations
Your application's run-time performance-its speed-is one of its most visible and
critical characteristics. Developing high-performance software that meets the expectations
</div>
</div>
<div id="mainNav">
<ul>
<li><a href="#">Menu1</a>
<ul>
<li>Sub1</li>
<li>Sub2</li>
<li>Sub3</li>
</ul>
</li>
<li>Menu2</li>
<li>Menu3</li>
</ul>
</div>
<div id="footer">
<p>
Footer Text</p>
</div>
</div>
</body>
</html>
效果: