27th Chapter CSS Traditional layout [top]
Learning Essentials:
1. Layout model
2. Table layout
3. Floating layout
This chapter focuses on the traditional layout used in the early days of CSS in HTML5, and in many cases, these layouts
is very useful.
A Layout model
In the early days of mobile devices such as tablets and smartphones, Web pages were designed primarily for
PC-side computer resolution is expanded. This resolution ratio is relatively single, basically as long as the minimum resolution design can be met.
In general there are 4:3, 16:10, 16:9 such major resolutions. So, from this scale, the length is always
Greater than the width. Design from a minimum resolution of 1024 * 768. In order to make the scroll bar not appear at the bottom of the browser,
Subtract the appropriate width, such as minus 28, and the final fixed length is set to 996. Of course, there are some websites in the near
For two years, the minimum resolution is set to 1280 minus the scrollbar width, as the large display is progressively mainstream.
In addition to the fixed-length layout just described, there is also a fluid layout, which is the length of the layout as a percentage,
such as 100%. No matter what resolution you are, it can be displayed in full screen, of course, the limitations are particularly large, only for some single
A page, a complex page, will create a variety of reading barriers with different browsers.
Two. Table layout
Table layout is the layout of the table border and fill implementation by setting a fixed cell. Of course this cloth
Bureau is very not recommended to use, just teach to understand. The table should use its most semantic place, that is, the data display of the two-dimensional table.
1. Fixed layout
//html section
<table border= "0";
<tr>
<td colspan= "2" class= "header" >header </td>
</tr>
<tr>
<td class= "aside" >ASIDE</TD>
<td class= "section" >section</td>
</tr>
<tr>
<td colspan= "2" class= "Footer" >footer</td>
</tr>
</table>
//css part
Body {
margin:0;
}
Table {
margin:0 auto;
width:960px;
border-spacing:0;
}
. header {
height:120px;
background-color:olive;
}
. aside {
width:200px;
height:500px;
Background-color:purple;
}
. section {
width:760px;
height:500px;
Background-color:maroon;
}
. footer {
height:120px;
Background-color:gray;
}
2. Fluid layout
It is easy to change the fixed layout of the table to a fluid layout, just set the table to 100%.
Modify Table
Table {
width:100%;
}
Three Floating layouts
Floating layouts are primarily built with float and clear two properties.
1. Fixed layout
HTML section
Header
<aside>
Aside
</aside>
<section>
Section
</section>
<footer>
Footer
</footer>
CSS Section
Body {
width:960px;
margin:0 Auto;
Color:white;
}
Header {
height:120px;
background-color:olive;
}
aside {
width:200px;
height:500px;
Background-color:purple;
Float:left;
}
Section {
width:760px;
height:500px;
Background-color:maroon;
Float:right;
}
Footer {
height:120px;
Background-color:gray;
Clear:both;
}
2. Fluid layout
Fluid layout As long as the body element is changed to a limited length of auto or 100%. Then the left and right two columns were set 20%
and 80%.
CSS Section
Body {
Width:auto;
}
aside {
width:20%;
}
Section {
width:80%;
}
Example:
<! DOCTYPE html>
<meta charset= "Utf-8" >
<TITLE>CSS traditional layout [Upper]</title>
<link rel= "stylesheet" type= "Text/css" href= "Style.css" >
<body>
<table border= "0" >
<tr>
<TD colspan= "2" class= "header" >header</td>
</tr>
<tr>
<TD class= "aside" >aside</td>
<TD class= "section" >section</td>
</tr>
<tr>
<TD colspan= "2" class= "Footer" >footer</td>
</tr>
</table>
</body>
@charset "Utf-8";
Body {
margin:0;
}
Table {
/*width:960px;*/
width:100%;
margin:0 Auto;
/*border-spacing:0px;*/
Border-collapse:collapse;
}
. header {
height:120px;
background-color:olive;
}
. aside {
width:200px;
height:500px;
Background-color:purple;
}
. Section {
width:760px;
Background-color:maroon;
}
. footer {
height:120px;
Background-color:gray;
}
Example 2
<! DOCTYPE html>
<meta charset= "Utf-8" >
<TITLE>CSS traditional layout [Upper]</title>
<link rel= "stylesheet" type= "Text/css" href= "Style2.css" >
<body>
Header
<aside>
Aside
</aside>
<section>
Section
</section>
<footer>
Footer
</footer>
</body>
@charset "Utf-8";
Body {
margin:0 Auto;
/*width:960px;*/
Width:auto;
}
Header {
height:120px;
background-color:olive;
}
aside {
/*width:200px;*/
width:20%;
/*min-width:120px;*/
height:500px;
Background-color:purple;
Float:left;
}
Section {
/*width:760px;*/
width:80%;
height:500px;
Background-color:maroon;
Float:right;
}
Footer {
height:120px;
Background-color:gray;
Clear:both;
}
27th CSS Traditional layout (top)