1、经典布局,上头下尾,两侧固定,中间自适应

效果图:

实现代码(普通):

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>test</title>
</head>
<style>
.header{
width:100%;
height:30px;
background-color:lightsalmon;
text-align: center;
}
.footer{
width:100%;
height:30px;
background-color:lightgreen;
text-align: center;
}
.left{
background-color:mediumaquamarine;
margin-left:0%;
width:10%;
}
.main{
background-color:lightseagreen;
width:80%;
}
.right{
background-color:lightcyan;
float:right;
width:10%;
}
.left,.main,.right{
height:100%;
min-height:500px;
display:inline-block;
text-align: center;
}
</style>
<body>
<div class="header">头部</div>
<div>
<div class="left">左边
</div><div class="main">中间
</div><div class="right">右边</div>
</div>
<div class="footer">尾部</div>
</body>
</html>

2、用flex实现经典布局

应用默认的排序flex-direction:row及flex布局的默认效果代替了float,display:inline-block等效果

代码示例:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>test</title>
</head>
<style>
.body{
display:flex;
flex-wrap: wrap;
}
.header{
width:100%;
height:30px;
background-color:lightsalmon;
text-align: center;
}
.footer{
width:100%;
height:30px;
background-color:lightgreen;
text-align: center;
}
.left{
background-color:mediumaquamarine;
width:10%;
}
.main{
background-color:lightseagreen;
width:80%;
}
.right{
background-color:lightcyan;
width:10%;
}
.left,.main,.right{
min-height:500px;
text-align: center;
}
</style>
<body>
<div class="body">
<div class="header">头部</div>
<div class="left">左边</div>
<div class="main">中间</div>
<div class="right">右边</div>
<div class="footer">尾部</div>
</div>
</body>
</html>

3、用网格实现经典布局

用grid-template-columns定义每个的列宽

用grid-column定义每一列从哪个网线开始,哪个网线截止

代码示例:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>test</title>
</head>
<style>
.body{
display:grid;
grid-template-columns: 1fr 5fr 1fr;
}
.header{
height:30px;
background-color:lightsalmon;
text-align: center;
grid-column: 1/4;
}
.footer{
width:100%;
height:30px;
background-color:lightgreen;
text-align: center;
grid-column: 1/4;
}
.left{
background-color:mediumaquamarine;
grid-column: 1/2;
}
.main{
background-color:lightseagreen;
grid-column: 2/3;
}
.right{
background-color:lightcyan;
grid-column: 3/4;
}
.left,.main,.right{
min-height:500px;
text-align: center;
}
</style>
<body>
<div class="body">
<div class="header">头部</div>
<div class="left">左边</div>
<div class="main">中间</div>
<div class="right">右边</div>
<div class="footer">尾部</div>
</div>
</body>
</html>

最新文章

  1. js创建与追加元素
  2. VMware中装Win2012并配置Hyper-v
  3. java学习第13天( java获取当前时间,有关大数据的运算及精确数字运算,Date类)
  4. 如果客户端禁用cookie,session还能使用吗?
  5. 【翻译】How To Tango With Django 1.5.4 第五章
  6. python——协程
  7. 【jQuery基础学习】12 jQuery学习感想
  8. sed命令用法详解
  9. TOAD Menu Shortcuts 快捷键
  10. 阻止长按复制页面中的内容;zepto中touch中的应用必须先加载event模块之后;
  11. day10、nfs+rsync全网备份及实时同步
  12. C++中explicit关键字
  13. 浅谈MySQL存储引擎-InnoDB&amp;MyISAM
  14. 使用 Topshelf 创建 Windows 服务
  15. win7x64上配置 vs2015
  16. nginx-启动|关闭|重新加载配置文件的命令
  17. gitlab:开发+测试+发布的全流程图
  18. 帝国cms系统限制的登录次数不得超过5次请等60分钟过后方可重新登录
  19. API接口规范
  20. kafka-python的API简单介绍

热门文章

  1. #在windows上使用ngix重定向目录访问远程服务器文件详细实例
  2. FBV与CBV 及CBV源码分析
  3. 简单易学的机器学习算法——决策树之ID3算法
  4. Qt之高DPI显示器(一) - 解决方案整理
  5. OC循环方法推荐-块循环遍历(比for循环好用)
  6. Python之Flask项目开发【入门必学】
  7. Python学习心得体会总结,不要采坑
  8. Orleans的深入
  9. Postman 关联接口测试(带有token鉴权)
  10. 一次使用pip后的总结