css3的盒子模型布局
写在前面的话:
css3盒子布局,可以更简单直观的均分页面某一个div,并且还可以达到均分后的每一个元素中的内容上下居中、左右居中,但是该模型对浏览器的版本有要求:


<style>
#Settings-div {
width: %;
height: 500px;/*开启盒子模型的框必须写长宽*/
background-color: #fff;
display: flex;/*开启盒子布局*/
flex-flow: column;/*竖向布局,指width不变height改变*/
/* display: -webkit-box;
-webkit-box-orient: vertical//竖向布局*/
} #Settings-header {
width: %;
height: .5em;/*如果不想按比例分配长宽可以自己写固定样式*/
line-height: .5em;
text-align: center;
font-size: .5em;
border-bottom: 1px solid #e5e5e5;
background-image: -moz-linear-gradient(top,#ffffff,#f7f7f7);
} #Content {
flex: ;
display: flex;
flex-flow: row;/*横向布局,如果是display: -webkit-box;则不用写布局方式,因为浏览器均默认为横向*/
} #Settings-list {
flex: ;
display: flex;
height: %;
flex-flow: column;
} #Settings-content {
flex: ;
height: %;
} #Settings-list div {
/*display: -webkit-box;//声明盒子模型下的所有div都按盒子模型布局
-webkit-box-align: center;//上下居中
-webkit-box-pack: center;//左右居中*/
display: flex;
justify-content: center;/*左右居中*/
align-items: center;/*上下居中*/
} .list-title {
flex: ;/*不单单是id可以写class也可以*/
background-image: -moz-linear-gradient(top,#ffffff,#f7f7f7);/*页面元素背景从上到下颜色渐变,怕你们看不懂,虽然与主题无关-moz是只能火狐识别的单独样式,-webkit是chrome、Safari、Opera为主的浏览器识别的样式 */
font-size: .2em;
border-right: 1px solid #e5e5e5;
} .list-content {
flex: ;
background-color: #f7f7f7;
border-top: 1px #e5e5e5 solid;
cursor: pointer;
border-right: 1px solid #e5e5e5;
} .action {
border-left: 5px solid #0094ff;
} .select {
background-color: #fff;
border-right: 0px;
} #Content-one {
width: %;
height: %;
} #Content-two {
width: %;
height: %;
} #Content-twodiv {
width: %;
height: %;
display: flex;
flex-flow: column;
}
/*由于没有给#Content-twodiv底下的div写布局模式,所以底下的div中的元素没用居中*/
#Content-two1 {
flex: ;
width: %;
display: flex;
flex-flow: row;
} #Content-two2 {
flex: ;
} #Content-three {
display: none;
} #form1 {
width: %;
height: %;
display: -webkit-box;/*另一种要写很多无意义的代码的写法*/
display: -moz-box;
-webkit-box-orient: vertical;
-moz-box-orient: vertical;
}
/*完全无意的浪费时间写的样式,实在是不推荐*/
#form1 div {
display: -webkit-box;
-webkit-box-pack: center;
-webkit-box-align: center;
display: -moz-box;
-moz-box-align: center;
-moz-box-pack: center;
} #form1-header {
width: %;
height: 50px;
font-size: .3em;
border-bottom: 1px solid #e5e5e5;
} #table {
width: %;
table-layout: auto;
margin-top: 10px;
} #table td {
width: %;
height: 40px;
line-height: 40px;
} .table-left {
text-align: right;
padding-right: 20px;
} .table-right {
padding-left: 20px;
} #save1 {
background-color: #aa56ff;
color: #ffffff;
width: 80px;
height: 35px;
border: 0px;
box-shadow: 2px 4px 6px #;
cursor: pointer;
} #save2 {
background-color: #aa56ff;
color: #ffffff;
width: 80px;
height: 35px;
border: 0px;
box-shadow: 2px 4px 6px #;
cursor: pointer;
} #age {
width: 25px;
border-color: #d8d8d8 #e5e5e5 #e5e5e5 #d8d8d8;
border-style: solid;
border-width: 1px;
} .table-right select {
width: 100px;
height: 30px;
border-color: #d8d8d8 #e5e5e5 #e5e5e5 #d8d8d8;
border-style: solid;
border-width: 1px;
}
</style>
<div id="Settings-div">
<div id="Settings-header">
<span>个人设置</span>
</div>
<div id="Content">
<div id="Settings-list">
<div class="list-title action">
<img src="~/images/user.png" />
<span>个人资料</span>
</div>
<div class="list-content select" data-leve="">
<span>基本资料</span>
</div>
<div class="list-content" data-leve="" style="border-bottom:1px #e5e5e5 solid ;">
<span>头像设置</span>
</div>
<div class="list-title">
<img src="~/images/mi.png" />
<span>隐私设置</span>
</div>
<div class="list-content" style="border-top:1px #e5e5e5 solid ;" data-leve="">
<span>修改密码</span>
</div>
</div>
<div id="Settings-content">
<div id="Content-one" class="content">
<form id="form1">
<div id="form1-header">
<span>基本资料</span>
</div>
<table id="table">
<tr>
<td class="table-left">性别:</td>
<td class="table-right">
<input type="radio" name="sex" value="男" checked />男
<input type="radio" name="sex" value="女" />女
</td>
</tr>
<tr>
<td class="table-left">年龄:</td>
<td class="table-right"><input type="text" name="age" id="age" value="" />岁</td>
</tr>
<tr>
<td class="table-left">居住地:</td>
<td class="table-right">
<select>
<option value="">请选择</option>
</select>
<select>
<option value="">请选择</option>
</select>
</td>
</tr>
</table>
<div>
<input type="button" id="save1" value="保存" />
</div>
</form>
</div>
<div id="Content-two" class="content" style="display:none;">
<div id="Content-twodiv">
<div id="Content-two1">
<div style="flex:2;background-color:#e2e2e2;"> </div>
<div style="width:290px;"></div>
</div>
<div id="Content-two2">
<form id="upload-imgs" action="/FileUpload/FileImages" method="post" enctype="multipart/form-data">
<input type="button" value="上传图片" style="" />
<input type="file" name="img" value="" style="opacity:0; margin-left:-80px;width:80px;cursor:pointer;" onchange="uploadFile(this)" />
</form>
</div>
</div>
</div>
<div id="Content-three" class="content" style="display:none;"> </div>
</div>
</div> </div>
css3的盒子模型布局的更多相关文章
- CSS3弹性盒模型布局模块介绍
来源:Robert’s talk原文:http://robertnyman.com/2010/12/02/css3-flexible-box-layout-module-aka-flex-box-in ...
- css3弹性盒子模型之box-flex
css3弹性盒子模型之box-flex 浏览器支持 目前没有浏览器支持 box-flex 属性. Firefox 支持替代的 -moz-box-flex 属性. Safari.Opera 以及 Chr ...
- css3弹性盒子模型
当下各种手机,平板尺寸不一,如果盒模型只能固定尺寸,不能随意压缩,将不能很好的迎合这个时代.所以css3推出了新的盒模型——弹性盒子模型(Flexible Box Model). 弹性盒模型可以水平布 ...
- 浅谈 css3 box盒子模型以及box-flex的使用
display:box;box-flex是css3新添加的盒子模型属性,它的出现可以解决我们通过N多结构.css实现的布局方式.经典的一个布局应用就是布局的垂直等高.水平均分.按比例划分. 一.使 ...
- css3弹性盒子 flex布局
CSS3 弹性盒 1.display:flex 说明: 设置为弹性盒(父元素添加) 2.flex-direction(主轴排列方式) 说明: 顺序指定了弹性子元素在父容器中的位置 row 默认在一行内 ...
- CSS3之盒子模型
display:box 使子元素成行排列如果父级宽度小于子级盒子 不会把超出部分挤出下面 而是直接超出 -box-orient:vertical 使盒子垂直显示 默认水平显示 -box-direct ...
- CSS3 Box-sizing(盒子模型)
http://www.w3cplus.com/content/css3-box-sizing http://tantek.com/CSS/Examples/boxmodelhack.html box- ...
- css3弹性盒子模型——回顾。
1.box-flex属性规定框的子元素是否可伸缩其尺寸. 父元素必须要声明display:box;子元素才可以用box-flex. 语法:box-flex:value; 示例: <style&g ...
- display Flex 盒子模型布局兼容Android UC
<!DOCTYPE html><html><head><meta charset="utf-8"><meta content= ...
随机推荐
- Mysql基础教程——mysql之一
教程列表:http://www.dxzy163.com/view/index7627.html 41 存储过程 40 全文索引与停止词 39 索引的管 38 索引概念 37 数据库备份与恢复 36 事 ...
- Bulk-Only传输协议 UFI命令块规范
USB设备分为5大类,即显示器.通信设备.音频设备.人机输入和海量存储.通常所用的U盘.移动硬盘均属于海量存储类.海量存储类的规范中包括4个独立的子规范,即CBI传输.Bulk-Only传输.ATA命 ...
- C语言必背18个经典程序
C语言必背18个经典程序 1./*输出9*9口诀.共9行9列,i控制行,j控制列.*/ #include "stdio.h" main() {int i,j,result; for ...
- 8051_asm.uew
/L20"8051 Assembly" AASM_LANG Line Comment = ; Nocase String Chars = ' File Extensions = S ...
- Dropbox 用什么语言开发的?(Python在各个平台都是全能的,特别是有PyObjC真没想到)
Dropbox 绝大部分是用 Python 开发的.用到 Python 的地方有:服务器后台.客户端.Dropbox 网页版前段.API 后台.数据分析. 在服务器端.桌面版客户端使用的是 Pytho ...
- FFmpeg深入分析之零-基础 <第一篇>
FFmpeg是相当强大的多媒体编解码框架,在深入分析其源代码之前必须要有基本的多媒体基础知识,否则其源代码会非常晦涩难懂.本文将从介绍一些基本的多媒体只是,主要是为研读ffmpeg源代码做准备,比如一 ...
- 用 Graphviz画神经网络图
用 Graphviz . 以下代码提供一个例子, 具体使用时做简单修改即可. digraph G { rankdir=LR splines=line nodesep=.05; node [label= ...
- mosquitto在Linux环境下的部署/安装/使用/测试
mosquitto在Linux环境下的部署 看了有三四天的的源码,(当然没怎么好好看了),突然发现对mosquitto的源码有了一点点感觉,于是在第五天决定在Linux环境下部署mosquitto. ...
- http://bassistance.de/jquery-plugins/
http://bassistance.de/jquery-plugins/ Query插件:手风琴 jQuery插件:自动完成 jQuery插件:留言 jQuery插件:密码验证 jQuery插件:P ...
- LeeCode-Pow(x, n)
Implement pow(x, n). double myPow(double x, int n) { ) return 1.0; ) return 1.0/pow(x,-n); ); }