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集合 □ 思路 比如为一个用 ...
随机推荐
- Android来电、去电监听
Android手机中添加手机来电的状态,使用PhoneStateListener来监听. TelephonyManager telephonyManager = (TelephonyManager) ...
- js判断浏览器类型以及语言
1.检查是否是移动端(Mobile).ipad.iphone.微信.QQ等 <script type="text/javascript"> //判断访问终端 var b ...
- [转载]Flip an image in UIImageView using UIView transitionWithView
View animations on the iPhone are wonderful. Used properly they will delight your users and help you ...
- 如何在NSDocumentDirectory内新建一个文件夹
iOS下载文件一般保存到NSDocumentDirectory内,但是为了更好整理文件内容,那就要自定义的生成一些文件夹,和做一些删除文件夹的操作. - (NSString *)pathToPatie ...
- 使用Git如何优雅的忽略掉一些不必的文件
熟悉使用Git之后发现,使用sourceTree来管理和开发项目会变得更高效,现在我用bitbucket管理自己的项目,它提供了私有的仓库,用起来还是比较爽,不过刚开始用的时候,只要一打开本地仓库的工 ...
- 编程开发之--Oracle数据库--存储过程使用动态参数绑定(3)
1.动态参数绑定,可以实现动态的执行不同的sql --创建包 create or replace PACKAGE MYPACKAGE AS type empcursor is ref cursor; ...
- springmvc.xml配置
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...
- list排序问题
用Collections.sort方法对list排序有两种方法第一种是list中的对象实现Comparable接口,如下: /*** 根据order对User排序*/public class User ...
- Ant demo
<?xml version="1.0" encoding="UTF-8"?> <!-- 定义一个工程,默认任务为warFile. --> ...
- Locust HTTP client
Http client 默认是以安全模式运行的,任何由于连接错误.超时或者类似错误引起的异常,都会返回一个空的Response对象,这个请求将会再locust统计中标记为failure,返回的虚拟对象 ...