1. css3的盒模型

css3中添加弹性盒模型,最新弹性盒模型是flex,之前为box

<!DOCTYPE html>
<html >
<head>
<title>div + css宽度自适应(液态布局)</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
/*左边栏,设定宽度*/
html,body{
width: 100%;
height: 100%;
margin: 0;
}
#wrap{
display: flex;
width: 100%;
height: 100%;
/*css3 的盒模型设置垂直排序 新老方法 box-orient老方法 flex-direction新方法*/
box-orient:vertical;
flex-direction:column;
}
.wrap_l
{
height: 150px;
width: 150px;
background: yellow;
}
/*中间栏,宽度auto,*/
.wrap_m
{
flex:1;
background: blue;
}
</style>
</head>
<body>
<div id="wrap">
<div class="wrap_l">
这是上边部分<br />
这是上边部分<br />
这是上边部分
</div>
<div class="wrap_m">
这是下部分
</div>
</div>
</body>
</html>

2.position: absolute;绝对布局解决方案

绝对布局主要相对它的父dom做的操作,一般父dom要有足够的空间,如果涉及嵌套太多,父dom可以设置为postion:relative

<!DOCTYPE html>
<html >
<head>
<title>div + css宽度自适应(液态布局)</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
/*左边栏,设定宽度*/
html,body{
width: 100%;
height: 100%;
margin: 0;
}
#wrap{
width: 100%;
height: 100%;
}
.wrap_l
{
height: 150px;
width: 150px;
background: yellow;
}
/*中间栏,宽度auto,*/
.wrap_m
{
position: absolute;
top:150px;
width: 100%;
background: blue;
bottom: 0px;
}
</style>
</head>
<body>
<div id="wrap">
<div class="wrap_l">
这是上边部分<br />
这是上边部分<br />
这是上边部分
</div>
<div class="wrap_m">
这是下部分
</div>
</div>
</body>
</html>

3.table布局

也可以用display:table仿table布局

display:table只支持IE8+以上

<!DOCTYPE html>
<html >
<head>
<title>div + css宽度自适应(液态布局)</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
/*左边栏,设定宽度*/
html,body{
width: 100%;
height: 100%;
margin: 0;
}
#wrap{
width: 100%;
height: 50%;
display: table;
}
.wrap_l
{
height: 100px;
display: table-row;
background: yellow;
}
/*中间栏,宽度auto,*/
.wrap_m
{
display: table-row;
background: blue;
}
</style>
</head>
<body>
<div id="wrap">
<div class="wrap_l">
这是上边部分<br />
这是上边部分<br />
这是上边部分
</div>
<div class="wrap_m">
这是下部分
</div>
</div>
<table style="height:50%;width:100%">
<tr style="background: red;height:100px"><td > 上部分</td></tr>
<tr style="background: yellow;"><td > 下部分</td></tr>
</table>
</div>
</body>
</html>

这就最终的结果

常见css垂直自适应布局(css解决方法)的更多相关文章

  1. DIV+CSS布局中自适应高度的解决方法

    div乱跑问题  (文件<DIV+CSS布局中自适应高度的解决方法.rar>)   float 是个很危险的东西 得小心使用 本来有一很好的关于CSS+DIV的论坛 不过现在关门了 甚是可 ...

  2. CSS流体(自适应)布局下宽度分离原则

    CSS流体(自适应)布局下宽度分离原则 这篇文章发布于 2011年02月28日,星期一,00:48,归类于 css相关. 阅读 73990 次, 今日 5 次 by zhangxinxu from h ...

  3. CSS+DIV自适应布局

    CSS+DIV自适应布局 1.两列布局(左右两侧,左侧固定宽度200px;右侧自适应占满) 代码如下: <!doctype html> <html> <head> ...

  4. 演示:纯CSS实现自适应布局表格

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  5. PHP开发中常见的安全问题详解和解决方法(如Sql注入、CSRF、Xss、CC等

    页面导航: 首页 → 网络编程 → PHP编程 → php技巧 → 正文内容 PHP安全 PHP开发中常见的安全问题详解和解决方法(如Sql注入.CSRF.Xss.CC等) 作者: 字体:[增加 减小 ...

  6. easyui 中iframe嵌套页面,大弹窗自适应居中的解决方法。$('#win').window()

    easyui 中iframe嵌套页面,大弹窗自适应居中的解决方法.$('#win').window() 以下是左边栏和头部外层遮罩显示和隐藏方法 /*外层 遮罩显示*/ function wrapMa ...

  7. javascript常见的20个问题与解决方法

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  8. 常见css水平自适应布局

    左右布局,左边固定,右边自适应布局 BFC方法解决 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ...

  9. CSS兼容性问题总结及解决方法

    css兼容问题 兼容问题 1.文字本身的大小不兼容.同样是font-size:14px的宋体文字,在不同浏览器下占的空间是不一样的,ie下实际占高16px,下留白3px,ff下实际占高17px,上留白 ...

随机推荐

  1. 《锋利的jQuery(第2版)》笔记-第2章-jQuery选择器

    选择器是jQuery的根基,在jQuery中,对事件处理.遍历DOM和Ajax操作都依赖于选择器.熟练使用选择器,不仅可以简化代码,而且可以达到事半功倍的效果. 2.1 jQuery选择器是什么 1. ...

  2. JavaScript 构造函数与原型链

    构造函数.原型链: function Person(name, age, job) { this.name = name; this.age = age; this.job = job; // thi ...

  3. 第一次做socket的一些心得

    理论什么的bilibala的就是自己百度吧 推荐一篇不错的关于socket的文章 http://www.cnblogs.com/sunway/archive/2010/01/29/1659074.ht ...

  4. nodejs学习笔记一

    一.node版本的更新命令 node有一个模块叫n,是专门用来管理node.js的版本的. 首先安装n模块: npm install -g n 第二步: 升级node.js到最新稳定版 n stabl ...

  5. Linux下实现秒级的crontab定时任务

    crontab的格式如下 * * * * * command 分 时 日 月 周 命令 第1列表示分钟1-59 每分钟用*或者 */1表示 第2列表示小时1-23(0表示0点) 第3列表示日期1-31 ...

  6. C和指针 第十五章 习题

    15.8 十六进制倾印码 #include <stdio.h> #include <stdlib.h> #include <string.h> #include & ...

  7. window.top.location.href 和 window.location.href 的区别

    "window.location.href"."location.href"是本页面跳转. "parent.location.href" 是 ...

  8. linux 比较两个文件是否一致

    diff source target 如果一致不弹出任何信息

  9. C语言 回文

    #include <stdio.h> #include <string.h> int main() { ]; int i,j; printf("Please inpu ...

  10. 51. 顺时针打印矩阵[print matrix in clockwise direction]

    [本文链接] http://www.cnblogs.com/hellogiser/p/print-matrix-in-clockwise-direction.html [题目] 输入一个矩阵,按照从外 ...