3. 从body元素开始弹性布局
把body元素定义为盒布局,并设置子元素水平居中。
广州网站建设
- body, html {
- margin:0;
- padding:0;
- width:100%;
- height:100%;
- font-family:Arial, Helvetica, sans-serif;
- }
- body {
- /* 开启盒布局 */
- display:-webkit-box;
- display:-moz-box;
- display:box;
- /* 设置盒子内元素水平居中 */
- -webkit-box-pack:center;
- -moz-box-pack:center;
- box-pack:center;
- }
4. 定义网页区域
设置网页区域的空间弹性以占满整个区域。使用盒布局,并设置垂直方向布局。
广州网站设计
- #area {
- height:100%;
- max-width:950px; /* 最大宽度 */
- min-width:600px; /* 最小宽度 */
- /* 定义空间弹性,使其充满页面空间,但宽度受max-width和min-width限制 */
- -webkit-box-flex:1;
- -moz-box-flex:1;
- box-flex:1;
- /* 开启盒布局 */
- display:-webkit-box;
- display:-moz-box;
- display:box;
- /* 垂直布局,实现竖直方向的三栏布局 */
- -webkit-box-orient:vertical;
- -moz-box-orient:vertical;
- box-orient:vertical;
- }
5. 设置页头、主体区域和页脚三个部分
设置页头、主体区域和页脚三个部分。其中,主体区域部分定义空间弹性,并使用盒布局及默认的水平方向。其他部分为常规样式表。
广州网站设计
- #area header {
- background-color:#ff6600;
- text-align:center;
- line-height:35px;
- color:#FFFFFF;
- font-size:24px;
- font-weight:bold;
- }
- #area #header {
- padding:15px;
- }
- #area #container {
- /* 定义空间弹,使其随空间伸缩尺寸 */
- -webkit-box-flex:1;
- -moz-box-flex:1;
- box-flex:1;
- /* 开启盒布局 */
- display:-webkit-box;
- display:-moz-box;
- display:box;
- }
- #area footer {
- background-color:#f47D31;
- text-align:center;
- line-height:20px;
- color:#FFFFFF;
- }
- #area #footer {
- padding:10px;
- }



