当前位置: 首页 > article >正文

【CSS/HTML】实现可扩展性的页面布局

文章目录

    • 1.左右结构,左边100%;右边宽度固定
    • 2.左右结构,左边固定,右边100%
    • 3.左中右结构,左边固定,右边固定,中间100%

前面有一篇文章讲过 《css实现两列布局,一列固定宽度,一列宽度自适应方法》,主要是讲实现一列固定宽度,一列宽度自适应的几种方法。

下面我在总结一下一般的三种扩展布局,这儿所示的扩展布局很常规,有的童鞋会说使用column或者flex啥的布局不是很方便吗,但是你也要看它的支持程度吧,比如你在手机端使用,那当然很好,那我要兼容IE8,IE9呢?

1.左右结构,左边100%;右边宽度固定

在这里插入图片描述

css代码:

#header{height:80px; background:#CCC;}
#center{overflow:hidden; zoom:1;}
#main_wrapper{float:left; width:100%; margin-top:10px; margin-left:-210px;}
#main{height:200px; margin-left:210px; background:#999;}
#sidebar{float:right; width:200px; margin-top:10px; height:200px; background:#AAA;}
#footer{height:50px; margin-top:10px; background:#CCC;}

HTML代码:

<div id="header"></div>
<div id="center">
    <div id="main_wrapper">
        <div id="main"></div>
    </div>
    <div id="sidebar"></div>
</div>
<div id="footer"></div>

2.左右结构,左边固定,右边100%

在这里插入图片描述

css代码:

#header{height:80px; background:#CCC;}
#center{overflow:hidden; zoom:1;}
#sidebar{float:left; width:200px; margin-top:10px; height:200px; background:#AAA;}
#main_wrapper{float:right; width:100%; margin-top:10px; margin-left:-210px;}
#main{height:200px; margin-left:210px; background:#999;}
#footer{height:50px; margin-top:10px; background:#CCC;}

HTML代码:

<div id="header"></div>
<div id="center">
    <div id="sidebar"></div>
    <div id="main_wrapper">
        <div id="main"></div>
    </div>
</div>

3.左中右结构,左边固定,右边固定,中间100%

在这里插入图片描述

css代码:

#header{height:80px; background:#CCC;}
#center{overflow:hidden; zoom:1;}
#sidebar-l {float:left; width:200px; margin-top:10px; height:200px; background:#AAA;}
#main-wrapper {margin-top:10px; float:left; width:100%; margin-left:-420px; height:200px;}
#main {margin-left:438px; background:#999; height:200px;}
#sidebar-r {float:right; width:200px; margin-top:10px; height:200px; background:#AAA;}
#footer{height:50px; margin-top:10px; background:#CCC;}

HTML代码:

<div id="header"></div>
<div id="center">
    <div id="sidebar-l">这里是左边</div>
    <div id="main-wrapper">
        <div id="main">这里是中间</div>
    </div>
    <div id="sidebar-r">这里是右边</div>
</div>
<div id="footer"></div>

http://www.kler.cn/news/330558.html

相关文章:

  • 2、.Net 前端框架:OpenAuth.Net - .Net宣传系列文章
  • PostgreSQL的学习心得和知识总结(一百五十二)|transaction_timeout:达到事务超时时终止会话
  • Redis中一些其他的数据类型渐进式遍历
  • FreeRTOS篇7:队列
  • 《程序猿之Redis缓存实战 · Redis 与数据库一致性》
  • 【大数据】大数据运维方案浅析总结
  • Vue.js组件开发详解
  • 【无人机设计与控制】Multi-UAV|多无人机多场景路径规划算法MATLAB
  • CSS常用属性、属性值
  • 云中红队系列 | 使用 Azure FrontDoor 混淆 C2 基础设施
  • 【艾思科蓝】Python数据分析与可视化实战:从入门到进阶
  • AI驱动的Java开发框架:Spring AI Alibaba实战部署教程
  • 滚雪球学MySQL[4.3讲]:MySQL表设计与优化:正规化、表分区与性能调优详解
  • 【ChatGPT】面向软件开发的提示词
  • Java - LeetCode面试经典150题 - 区间 (三)
  • pdf处理2
  • Android—ANR日志分析
  • Python知识点:如何使用Hive与PyHive进行数据仓库操作
  • 第四十一篇-Docker安装Neo4j
  • 使用pytdx获取历史股票行情