非常好的CSS基本布局16例
单行单列

单行单列1:采用float浮在左上角,固定宽度。
#content { float: left; padding: 10px; margin: 20px; background: #FFF; border: 5px solid #666; width: 400px; /* ie5win fudge begins */ voice-family: "\\"}\\""; voice-family:inherit; width: 370px; }html>body #content { width: 370px; /* ie5win fudge ends */ }

单行单列2:固定在左上角,固定宽度,采用的是绝对(absolute)定位。
#content { position: absolute; top: 0px; left: 0px; padding: 10px; margin: 20px; background: #FFF; border: 5px solid #666; width: 400px; /* ie5win fudge begins */ voice-family: "\\"}\\""; voice-family:inherit; width: 370px; }html>body #content { width: 370px; /* ie5win fudge ends */ }

单行单列3:固定在左上角,不固定宽度,采用百分比(%)定义宽度来自适应页面。

单行单列4(推荐):固定宽度,采用在body样式中定义居中属性(text-align: center;)实现适应页面自动居中。
单行两列


单行两列1:两列都固定宽度。第一列浮在左上角,第二列浮在第一列右边。

单行两列2:两列都百分比宽度,但不满屏。第一列固定在左上角,第二列浮在第一列右边。

单行两列3:两列都百分比宽度,满屏。两列都采用绝对定位。

单行两列4:两列都百分比宽度,满屏。第一列浮在左上角,第二列浮在右上角。

单行两列5:两列都百分比宽度,满屏。第一列浮在左上角,第二列浮在第一列右边。
单行三列

单行三列1:左右列都绝对定位(右列定位在右上)。左列和右列固定宽度,中间列自适应页面。

单行三列2:左列定位在左上,右列定位在右上,中间列浮在左列右面。左列和右列固定宽度,中间列自适应页面。

单行三列3:三列都绝对定位。左列和右列固定宽度,中间列根据内容自适应。

单行三列4(推荐):类似样式2,只是将margin: 20px属性增加在body样式中,解决了中间列在Netscape6.0中置顶的问题。

单行三列5:左右列绝对定位,中间列自适应。宽度满屏。
顶行三列


顶行三列1(推荐):顶行自适应页面宽度。左右列绝对定位,中间列自适应页面。

- 顶行三列2:宽度满屏
下一篇:中文排版CSS心得