DIV固定宽度和动态拉伸混合水平排列
1.效果图

2.源代码
html
<h2>1.头部固定,尾部拉伸</h2>
<div class="container" id="div1">
<div class="head"></div>
<div class="tail"></div>
</div> <h2>2.尾部固定,头部拉伸</h2>
<div class="container" id="div2">
<div class="tail"></div>
<div class="head"></div>
</div> <h2>3.头尾固定,中间拉伸</h2>
<div class="container" id="div3">
<div class="head"></div>
<div class="tail"></div>
<div class="center"></div>
</div> <h2>4.中间固定,两头拉伸</h2>
<div class="container" id="div4">
<div class="head">
<div class="inner"></div>
</div>
<div class="tail">
<div class="inner"></div>
</div>
<div class="center"></div>
</div>
css
<!-- 样式 -->
<style type="text/css">
/* 容器宽度为100% */
.container{
width: 100%;
} /** 头部div固定宽度 **/
#div1 .head{
width: 200px;
height: 100px;
background-color: #00F7DE;
float: left;
} /** 尾部div自动填充拉伸 **/
#div1 .tail{
width: auto; /** 宽度不写或者auto都行 **/
height: 100px;
margin-left: 200px;
background-color: #FFB800;
} /** 尾部div固定宽度 **/
#div2 .tail{
width: 200px;
height: 100px;
background-color: #FFB800;
float: right;
} /** 头部div自动填充拉伸 **/
#div2 .head{
width: auto;
height: 100px;
margin-right: 200px;
background-color: #00F7DE;
} #div3 .head{
width: 200px;
height: 100px;
background-color: #00F7DE;
float:left
} #div3 .center{
width:auto;
height: 100px;
background-color: #009f95;
margin-left: 200px;
margin-right: 200px;
} #div3 .tail{
width:200px;
height: 100px;
background-color:#FFB800;
float: right;
} #div4{
position: relative;
} #div4 .head{
width: 50%;
height: 100px;
float: left;
} #div4 .head .inner{
height: 100px;
background-color: #00F7DE;
margin-right: 100px;
} #div4 .tail{
width: 50%;
height: 100px;
float: left;
} #div4 .tail .inner{
height: 100px;
background-color:#FFB800;
margin-left: 100px;
} #div4 .center{
position: absolute;
width: 200px;
height: 100px;
left: 50%;
margin-left: -100px;
background-color: #009f95;
}
</style>
DIV固定宽度和动态拉伸混合水平排列的更多相关文章
- li 水平排列并自动填满 ul
找了li 如何水平排列并自动填满 ul,同时 li 宽度平均?资料,里面有提到"请用js动态计算保证兼容性", 因为我想实现的是,水平滚动条,ul的上级div是固定的宽度1000p ...
- Bootstrap 表单和图片 (内联表单,表单合组,水平排列,复选框和单选框,下拉列表,校验状态,添加额外的图标,控制尺寸,图片)
一.表单 基本格式 注:只有正确设置了输入框的 type 类型,才能被赋予正确的样式. 支持的输入框控件 包括:text.password.datetime.datetime-local.date.m ...
- 在bootstrap中让竖向排列的输入框水平排列
在bootstrap中可以使用自带的样式标记来控制样式,但是同时可以利用最原始的css样式来解决达到需求 如下所示可以看出来两个inline-block就可以使得两个水平排列 block和inline ...
- Bootstrap3 栅格系统-实例:从堆叠到水平排列
使用单一的一组 .col-md-* 栅格类,就可以创建一个基本的栅格系统,在手机和平板设备上一开始是堆叠在一起的(超小屏幕到小屏幕这一范围),在桌面(中等)屏幕设备上变为水平排列.所有"列( ...
- css怎么让li水平排列和div居中
让li向左浮动即可 给div定一个宽度,然后margin:0 auto;即可:
- 实现左边div固定宽度,右边div自适应撑满剩下的宽度的布局方式:
html: <div class="container"> <div class="left"> left固定宽度200px </ ...
- div居中(内容+元素:水平+垂直)
内容水平居中 text-align: center; 内容垂直居中 /*第一种 行内垂直居中*/ height: 43px; line-height:43px; /*我们将行距增加到和整个div一样高 ...
- Bootstrap3 表单-水平排列的表单
通过为表单添加 .form-horizontal 类,并联合使用 Bootstrap 预置的栅格类,可以将 label 标签和控件组水平并排布局.这样做将改变 .form-group 的行为,使其表现 ...
- MVC扩展生成CheckBoxList并水平排列
本篇体验生成CheckBoxList的几个思路,扩展MVC的HtmlHelper生成CheckBoxList,并使之水平排开. 通过遍历从控制器方法拿到的Model集合 □ 思路 比如为一个用 ...
随机推荐
- 【bzoj4889】: [Tjoi2017]不勤劳的图书管理员 分块-BIT
[bzoj4889]: [Tjoi2017]不勤劳的图书管理员 题目大意:给定一个序列(n<=50000),每个数有一个编码ai(ai<=50000)和权值vi(vi<=100000 ...
- Python strip()函数用法
Python中字符串处理函数里有三个去空格(包括'\n', '\r', '\t', ' ')的函数: strip 同时去掉左右两边的空格lstrip 去掉左边的空格rstrip 去掉右边的空格 具体示 ...
- 使用单个httpclient实例请求数据。
做J2EE的都知道httpclient这个工具,Android也自带这个工具,不过和J2EE上的不一样,可能是google在添加的时候,自己修改了一部分代码. 在J2EE中可以使用如下代码,在多线程的 ...
- Openfire服务端源代码开发配置指南[转]
转自:http://www.micmiu.com/opensource/openfire/openfire-src-config/ 本文将图文介绍如何把openfire(以3.8.1为例)源码配置 ...
- logo back 日志 发送邮件
<?xml version="1.0" encoding="UTF-8"?> <configuration> <!--<pr ...
- [HDU4035] Maze(概率DP)
HDU4035 有\(n\)个房间 , 由\(n-1\)条隧道连通起来 , 实际上就形成了一棵树 , 从结点\(1\)出发 , 开始走 , 在每个结点\(i\)都有\(3\)种可能 : \(1.\)被 ...
- 数组合并去重Array.from
function uniqArr(){ if(arguments.length == 0) return []; var arr = arguments[0]; for(var i=1;i<ar ...
- Django Rest Framework(阿奇)
Django Rest Framework 一. 什么是RESTful REST与技术无关,代表的是一种软件架构风格,REST是Representational State Transfer的简称,中 ...
- WinForm的Chart图形控件
/// <summary>画条形图的方法 /// </summary> /// <param name="arr">条形值数组参数</pa ...
- try-catch里面加了return后,finally还会执行吗?
请看下面的方法,在我们的catch里面,捕获到了异常之后,我们的catch模块里面的语句,还会接着执行,当我们执行到return之后,我们不会立即返回,而是会接着执行finally块里面的代码,只有执 ...