css3伸缩布局属性总结
http://www.css88.com/book/css/properties/flex/flex-basis.htm
http://c7sky.com/dive-into-flexbox.html
http://www.css88.com/archives/5741
http://caibaojian.com/demo/flexbox/align-items.html
http://caibaojian.com/demo/flexbox/align-content.html
一共2个标准一个是dispaly:box ;老的,另一个是dispaly:flex
用在父容器上的值:
div{
display: -webkit-box;
display: -moz-box;
display: -o-box;
display: -ms-flexbox;
display: -webkit-flex;
display: -moz-flex;
display: -ms-flex;
display: -o-flex;
display: flex;
-webkit-flex-wrap:wrap;
flex-direction:wrap;
align-content:flex-start;
-webkit-box-pack:end;-moz-box-pack:end;-ms-box-pack:end;
-webkit-box-align:stretch;-moz-box-align:stretch;-ms-box-align:stretch
-webkit-box-orient:vertical;-moz-box-orient:vertical;-ms-box-orient:vertical
}
align-content 属性在当灵活容器内的各项没有占用交叉轴上所有可用的空间时对齐容器内的各项(垂直)。
提示:使用 justify-content 属性对齐主轴上的各项(水平)。
justify-content:在子元素 不是flex的时候起作用,可以单行
align-content
会更改 flex-wrap
的行为。他只能多行使用,它和 align-items
相似,但是不是对齐伸缩项目,它对齐的是伸缩行。可能你已经想到了,它接受的值也很相似:
当伸缩容器的侧轴还有多余空间时,本属性可以用来调准「伸缩行」在伸缩容器里的对齐方式,这与调准伸缩项目在主轴上对齐方式的 <' justify-content '> 属性类似。请注意本属性在只有一行的伸缩容器上没有效果。
- 对应的脚本特性为alignContent。
用在子容器上的值: box-flex flex-grow flex-shrink flex-basis order
.flex-container {
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-flex-wrap: nowrap;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
-webkit-justify-content: flex-start;
-ms-flex-pack: start;
justify-content: flex-start;
-webkit-align-content: flex-end;
-ms-flex-line-pack: end;
align-content: flex-end;
-webkit-align-items: stretch;
-ms-flex-align: stretch;
align-items: stretch;
background: #000;
height:200px;
}
.flex-item{background: #fe6;margin:2px; padding:5px} .flex-item:nth-child(1) {
-webkit-order: 0;
-ms-flex-order: 0;
order: 0;
-webkit-flex: 1 1 auto;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
-webkit-align-self: auto;
-ms-flex-item-align: auto;
align-self: auto;
} .flex-item:nth-child(2) {
-webkit-order: 0;
-ms-flex-order: 0;
order: 0;
-webkit-flex: 1 1 auto;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
-webkit-align-self: auto;
-ms-flex-item-align: auto;
align-self: auto;
} .flex-item:nth-child(3) {
-webkit-order: 0;
-ms-flex-order: 0;
order: 0;
-webkit-flex: 1 1 auto;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
-webkit-align-self: auto;
-ms-flex-item-align: auto;
align-self: auto;
} .flex-item:nth-child(4) {
-webkit-order: 0;
-ms-flex-order: 0;
order: 0;
-webkit-flex: 0 1 auto;
-ms-flex: 0 1 auto;
flex: 0 1 auto;
-webkit-align-self: auto;
-ms-flex-item-align: auto;
align
Flexbox 规范时间表:
- 2009年7月 工作草案 (display: box;)
- 2011年3月 工作草案 (display: flexbox;)
- 2011年11月 工作草案 (display: flexbox;)
- 2012年3月 工作草案 (display: flexbox;)
- 2012年6月 工作草案 (display: flex;)
- 2012年9月 候选推荐 (display: flex;)
浏览器商为了自救,搞了个私有前缀,因此定义一个伸缩盒特别麻烦:
因此我在定下第2个规范,CSS统一用less来写。less是一种动态的样式表语言,它为CSS增加变量,组合,函数,运算等语法,让CSS更便于编写,复用与维护。 有了less,上面那一坨东西可以封装成一个函数,用不着每次都写这么多让你狂抓的候选值。
.flexbox() {//定义
// 2009 spec
display: -webkit-box;
display: -moz-box;
display: -o-box;
// tweener
display: -ms-flexbox;
// new spec
display: -webkit-flex;
display: -moz-flex;
display: -ms-flex;
display: -o-flex;
display: flex;
}
div{
.flexbox();//使用
}
我已经把与伸缩盒相关的东西都封装为一个less库,大家可以到这里下
// display: flex .flexbox() {
// 2009 spec
display: -webkit-box;
display: -moz-box;
display: -o-box; // tweener
display: -webkit-flexbox;
display: -moz-flexbox;
display: -ms-flexbox;
display: -o-flexbox; // new spec
display: -webkit-flex;
display: -moz-flex;
display: -ms-flex;
display: -o-flex;
display: flex;
} // flex //
.flex(@flex) {
-webkit-box-flex: @flex;
-moz-box-flex: @flex;
-o-box-flex: @flex;
box-flex: @flex;
-webkit-flex: @flex;
-moz-flex: @flex;
-ms-flex: @flex;
-o-flex: @flex;
flex: @flex;
}
@flexvalue: 1 1 auto;
// flex-derection = box-orient + box-direction
.flex-direction(@direction) when (@direction = row) {
-webkit-box-orient: horizontal;
-moz-box-orient: horizontal;
-webkit-flex-direction: row;
-moz-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
}
.flex-direction(@direction) when (@direction = row-reverse) {
-webkit-box-orient: horizontal;
-moz-box-orient: horizontal;
-webkit-box-direction: reverse;
-moz-box-direction: reverse;
-webkit-flex-direction: row-reverse;
-moz-flex-direction: row-reverse;
-ms-flex-direction: row-reverse;
flex-direction: row-reverse;
}
.flex-direction(@direction) when (@direction = column) {
-webkit-box-orient: vertical;
-moz-box-orient: vertical;
-webkit-flex-direction: column;
-moz-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
}
.flex-direction(@direction) when (@direction = column-reverse) { //http://www.w3school.com.cn/cssref/pr_box-orient.asp
-webkit-box-orient: vertical;
-moz-box-orient: vertical;
-webkit-box-direction: reverse;
-moz-box-direction: reverse;
-webkit-flex-direction: column-reverse;
-moz-flex-direction: column-reverse;
-ms-flex-direction: column-reverse;
flex-direction: column-reverse;
}
.flex-direction(@direction) {
-webkit-flex-direction: @direction;
-moz-flex-direction: @direction;
-ms-flex-direction: @direction;
-o-flex-direction: @direction;
flex-direction: @direction;
} // order //
.order(@order) {
-webkit-box-ordinal-group: @order + 1;
-moz-box-ordinal-group: @order + 1;
-o-box-ordinal-group: @order + 1;
-webkit-order: @order;
-moz-order: @order;
-ms-order: @order;
-o-order: @order;
order: @order;
} //justify content// //2009 property is box-pack
//2009 property does not support a method for space-around //start
//end
//center
//justify .justify-content(@justify-method) when (@justify-method = flex-start) {
-webkit-box-pack: start;
-moz-box-pack: start;
-ms-flex-pack: start;
-o-box-pack: start;
box-pack: start;
justify-content: flex-start;
} .justify-content(@justify-method) when (@justify-method = flex-end) {
-webkit-box-pack: end;
-moz-box-pack: end;
-ms-flex-pack: end;
-o-box-pack: end;
box-pack: end;
justify-content: flex-end;
} .justify-content(@justify-method) when (@justify-method = center) {
-webkit-box-pack: center;
-moz-box-pack: center;
-ms-flex-pack: center;
-o-box-pack: center;
box-pack: center;
justify-content: center;
} .justify-content(@justify-method) when (@justify-method = space-between) {
-webkit-box-pack: justify;
-moz-box-pack: justify;
-ms-flex-pack: justify;
-o-box-pack: justify;
box-pack: justify;
justify-content: space-between;
}
// note there is no fallback 2009 spec support for space-around
.justify-content(@justify-method) when (@justify-method = space-around) {
-webkit-box-pack: justify;
-moz-box-pack: justify;
-ms-flex-pack: distribute;
-o-box-pack: justify;
box-pack: justify;
justify-content: space-around;
} // 2011 spec // flex-start (default): items are packed toward the start line
// flex-end: items are packed toward to end line
// center: items are centered along the line
// space-between: items are evenly distributed in the line; first item is on the start line, last item on the end line
// space-around: items are evenly distributed in the line with equal space around them .justify-content(@justify-method) {
-webkit-justify-content: @justify-method;
-moz-justify-content: @justify-method;
-ms-justify-content: @justify-method;
-o-justify-content: @justify-method;
justify-content: @justify-method;
} .align-items(@align-method) when (@align-method = flex-start ){
-moz-box-align: start ;//https://developer.mozilla.org/en-US/docs/Web/CSS/box-align
-webkit-box-align: start ;
-ms-flex-align: start;//http://realworldvalidator.com/css/module/Microsoft/-ms-flex-align
-webkit-align-items: flex-start;
align-items: flex-start;
}
.align-items(@align-method) when (@align-method = flex-end ){
-moz-box-align: end;
-webkit-box-align: end;
-ms-flex-align: end;
-webkit-align-items: flex-end;
align-items: flex-end;
}
.align-items(@align-method) when (@align-method = center ){
-moz-box-align: center;
-webkit-box-align: center;
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
}
.align-items(@align-method) when (@align-method = baseline ){
-moz-box-align: baseline;
-webkit-box-align: baseline;
-ms-flex-align: baseline;
-webkit-align-items: baseline;
align-items: baseline;
}
.align-items(@align-method) when (@align-method = stretch ){
-moz-box-align: stretch;
-webkit-box-align: stretch;
-ms-flex-align: stretch;
-webkit-align-items: stretch;
align-items: stretch;
}
.align-items(@align-method){
-moz-box-align: @align-method;
-webkit-box-align: @align-method;
-ms-flex-align: @align-method;
-webkit-align-items: @align-method;
align-items: @align-method;
}
.flex-wrap(@wrap-method) when(@wrap-method = nowrap){
-ms-flex-wrap:none;
-moz-flex-wrap:nowrap;
-webkit-flex-wrap: nowrap;
flex-wrap: nowrap;
}
.flex-wrap(@wrap-method) when(@wrap-method = wrap){
-ms-flex-wrap:wrap;
-moz-flex-wrap:wrap;
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
}
.flex-wrap(@wrap-method) when(@wrap-method = wrap-reverse){
-ms-flex-wrap:wrap-reverse;
-moz-flex-wrap:wrap-reverse;
-webkit-flex-wrap: wrap-reverse;
flex-wrap: wrap-reverse;
}
.flex-wrap(@wrap-method){
-ms-flex-wrap:@wrap-method;
-moz-flex-wrap:@wrap-method;
-webkit-flex-wrap:@wrap-method;
flex-wrap:@wrap-method;
}
.align-self(@value) when(@value = flex-start){
-webkit-align-self: flex-start;
-ms-flex-item-align: start;
align-self: flex-start;
}
.align-self(@value) when(@value = flex-end){
-webkit-align-self: flex-end;
-ms-flex-item-align: end;
align-self: flex-end;
}
.align-self(@value) when(@value = center){
-webkit-align-self: center;
-ms-flex-item-align: center;
align-self: center;
}
.align-self(@value) when(@value = baseline){
-webkit-align-self: baseline;
-ms-flex-item-align: baseline;
align-self: baseline;
}
.align-self(@value) when(@value = stretch){
-webkit-align-self: stretch;
-ms-flex-item-align: stretch;
align-self: stretch;
}
.align-self(@value){
-webkit-align-self:@value;
-ms-flex-item-align:@value;
lign-self:@value
} //===========================================================
// http://stackoverflow.com/questions/15662578/flexible-box-model-display-flex-box-flexbox by RubyLouvre
.user-select(){
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.fixed-width(@value){
width:@value;
min-width:@value;
max-width:@value;
}
.fixed-height(@value){
height:@value;
min-height:@value;
max-height:@value;
}
.box-sizing(@value){
-webkit-box-sizing: @value; /* Safari/Chrome, other WebKit */
-moz-box-sizing:@value; /* Firefox, other Gecko */
box-sizing: @value; /* Opera/IE 8+ */
}
.brimming(){
width: 100%;
height: 100%;
}
.transform(@value){
transform:@value;
-moz-transform:@value;
-webkit-transform:@value;
-ms-transform:@value;
}
.box-shadow(@value){
-webkit-box-shadow: @value;
-moz-box-shadow: @value;
-ms-box-shadow:@value;
box-shadow:@value;
}
//=========================================================
css3伸缩布局属性总结的更多相关文章
- CSS3 伸缩布局盒模型记
CSS3 伸缩布局盒模型 CSS3引入的布局模式Flexbox布局,主要思想是让容器有能力让其子项目能够改变其宽度,高度,以最佳方式填充可用空间.Flex容器使用Flex项目可以自动放大与收缩,用来填 ...
- css3伸缩布局中justify-content详解
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- CSS3 伸缩布局盒模型
CSS3引入的布局模式Flexbox布局,主要思想是让容器有能力让其子项目能够改变其宽度,高度,以最佳方式填充可用空间.Flex容器使用Flex项目可以自动放大与收缩,用来填补可用的空闲空间.更重要的 ...
- CSS3——伸缩布局及应用
CSS3在布局方面做了非常大的改进,使得我们对块级元素的布局排列变得十分灵活,适应性非常强,其强大的伸缩性,在响应式开中可以发挥极大的作用. 主轴:Flex容器的主轴主要用来配置Flex项目,默认是水 ...
- CSS3伸缩布局Flex学习笔记
如果需要使用伸缩布局首先得把display:flex;对于兼容还得加前缀display:-webkit-display:flex;等其他浏览器前缀,但我本机Chrome测试已经不需要加前缀了,其实这些 ...
- css3 伸缩布局 display:flex等
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 第 29 章 CSS3 弹性伸缩布局[下]
学习要点: 1.新版本 主讲教师:李炎恢 本章主要探讨 HTML5 中 CSS3 提供的用来实现未来响应式弹性伸缩布局方案,这里做一个初步的了解. 一.新版本 新版本的 Flexbox 模型是 201 ...
- 第 29 章 CSS3 弹性伸缩布局[中]
学习要点: 1.混合过度版 主讲教师:李炎恢 本章主要探讨 HTML5 中 CSS3 提供的用来实现未来响应式弹性伸缩布局方案,这里做一个初步的了解. 一.混合过渡版 混合版本的 Flexbox 模型 ...
- 第 29 章 CSS3 弹性伸缩布局[上]
学习要点: 1.布局简介 2.旧版本 主讲教师:李炎恢 本章主要探讨 HTML5 中 CSS3 提供的用来实现未来响应式弹性伸缩布局方案,这里做一个初步的了解. 一.布局简介 CSS3 提供一种崭新的 ...
随机推荐
- VS2010 刷新工具箱(刷新自定义控件)
有时候自己自定义了控件,定义完后却不见工具箱中刷新出来自定义的控件,解决方案有了三种: 点评:在项目中增加了几个自定义控件,想在窗口上添加时却发现工具箱根本就没有些控件,晕了.记得2008都可以自动出 ...
- [读书笔记] java类初始化
以下内容来自周志明的<深入理解java虚拟机>: 类初始化阶段是类加载过程的最后一步,前面的类加载过程中,除了在加载阶段用户应用程序可以通过自定义类加载器参与之外,其余动作完全由虚拟机主导 ...
- Codeforces Round #164 (Div. 2)
A. Games 模拟. B. Buttons 简单计数. C. Beautiful Sets of Points 显然每行每列只能有一个点,那么最大点数为\(1+min(n, m)\). 在不考虑\ ...
- crontabs Permission denied
问题 jack@somemachine /data/jack $ crontab -e crontabs/jack: Permission denied 解决办法 sudo chown root:cr ...
- 获得图片颜色---摘自php手册
Example #1 imagecolorsforindex() 例子 ;$color_index = imagecolorat($im, $start_x, $start_y); // 使其可读$c ...
- Hbase条件筛选
需求来自于,模糊查找当天的所有记录,并查找对应列的记录数 public static void main(String[] args) throws Exception{ //创建HBase连接 Co ...
- Hibernate工作原理
现在我们知道了一个概念Hibernate Session,只有处于Session管理下的POJO才具有持久化操作能力.当应用程序对于处于Session管理下的POJO实例执行操作时,Hibernate ...
- svn 提交失败
刚刚使用SVN 提交代码时提示失败. svn: Commit failed (details follow):svn: Can't open file '/home/svn/project/db/tx ...
- 全面了解 Linux 服务器 - 1. 查看 Linux 服务器的 CPU 详细情况
1. 查看 Linux 服务器的 CPU 详细情况 判断依据: 具有相同的 core id 的 CPU 是同意个 core 超线程. 具有相同的 physical id 的 CPU 是同一个 CPU ...
- HTTP调试工具扩展
★Fiddler神器之一,IE-WinNet-Fiddler-Server,能跟踪调试HTTP和HTTPS是优点也是缺点. 地址:http://www.fiddler2.com/ ★Charles,可 ...