CSS3 flex盒子布局 常用封装 包含部分浏览器适配

可观看大神文档

链接: http://www.ruanyifeng.com/blog/2015/07/flex-grammar.html

代码拷贝可用

.flex {
	display: -webkit-box;	/* 老版本语法: Safari 3.1-6, iOS 6-, Android browser, older WebKit browsers. */
	display: -moz-box;		/* 老版本语法: Firefox 19- (buggy but mostly works) */
	display: -ms-flexbox;	/* 混合版本语法: IE 10 */
	display: -webkit-flex;	/* 新版本语法: Chrome 21+ */
	display: flex;			/* 新版本语法: Opera 12.1, Firefox 22+ */    
}

.basis-xs {
	flex-basis: 20%;
}

.basis-sm {
	flex-basis: 40%;
}

.basis-df {
	flex-basis: 50%;
}

.basis-lg {
	flex-basis: 60%;
}

.basis-xl {
	flex-basis: 80%;
}

.flex-sub {
	-webkit-box-flex: 1;    /* OLD - iOS 6-, Safari 3.1-6 */  
	-moz-box-flex: 1;       /* OLD - Firefox 19- */  
	-ms-flex: 1;            /* IE 10 */  
	-webkit-flex: 1;        /* Chrome */  
	flex: 1;                /* NEW, Spec - Opera 12.1, Firefox 20+ */
}

.flex-twice {
	-webkit-box-flex: 2;    /* OLD - iOS 6-, Safari 3.1-6 */
	-moz-box-flex: 2;       /* OLD - Firefox 19- */  
	-ms-flex: 2;            /* IE 10 */  
	-webkit-flex: 2;        /* Chrome */  
	flex: 2;                /* NEW, Spec - Opera 12.1, Firefox 20+ */
}

.flex-treble {
	-webkit-box-flex: 3;    /* OLD - iOS 6-, Safari 3.1-6 */
	-moz-box-flex: 3;       /* OLD - Firefox 19- */  
	-ms-flex: 3;            /* IE 10 */  
	-webkit-flex: 3;        /* Chrome */  
	flex: 3;                /* NEW, Spec - Opera 12.1, Firefox 20+ */
}
.flex-fourfold{
	-webkit-box-flex: 4;    /* OLD - iOS 6-, Safari 3.1-6 */
	-moz-box-flex: 4;       /* OLD - Firefox 19- */  
	-ms-flex: 4;            /* IE 10 */  
	-webkit-flex: 4;        /* Chrome */  
	flex: 4;                /* NEW, Spec - Opera 12.1, Firefox 20+ */
}

/* 主轴从上到下 */
.flex-zTopBottom {
	-webkit-box-direction: normal;
	-webkit-box-orient: vertical;
	-moz-flex-direction: column;
	-webkit-flex-direction: column;
	-ms-flex-direction: column;
	flex-direction: column;
}

/* 主轴从下到上 */
.flex-zBottomTop {
    -webkit-box-pack: end;
    -webkit-box-direction: reverse;
    -webkit-box-orient: vertical;
    -moz-flex-direction: column-reverse;
    -webkit-flex-direction: column-reverse;
    flex-direction: column-reverse;
}

/* 主轴从左到右 */
.flex-zLeftRight {
    -webkit-box-direction: normal;
    -webkit-box-orient: horizontal;
    -moz-flex-direction: row;
    -webkit-flex-direction: row;
    flex-direction: row;
}

/* 主轴从右到左 */
.flex-zRightLeft {
    -webkit-box-pack: end;
    -webkit-box-direction: reverse;
    -webkit-box-orient: horizontal;
    -moz-flex-direction: row-reverse;
    -webkit-flex-direction: row-reverse;
    flex-direction: row-reverse;
}

.flex-wrap {
	-webkit-box-lines: multiple;
	-moz-box-lines: multiple;
	-o-box-lines: multiple;
	-webkit-flex-wrap: wrap;
	-ms-flex-wrap: wrap;
	flex-wrap: wrap;
}

.align-start {
	-webkit-box-align: start;
	-moz-box-align: start;
	-o-box-align: start;
	-ms-flex-align: start;
	-webkit-align-items: flex-start;
	align-items: flex-start;
}

.align-end {
	-webkit-box-align: end;
	-moz-box-align: end;
	-o-box-align: end;
	-ms-flex-align: end;
	-webkit-align-items: flex-end;
	align-items: flex-end;
}

.align-center {
	/* -webkit-box-pack: center;
	-moz-box-pack: center;
	-o-box-pack: center;
	-ms-flex-pack: center;
	-webkit-align-items: center; */
	align-items: center;
}

.align-stretch {
	-webkit-box-align: stretch;
	-moz-align-items: stretch;
	-webkit-align-items: stretch;
	align-items: stretch;
}

.flex-baseline {
    -webkit-box-align: baseline;
    -moz-align-items: baseline;
    -webkit-align-items: baseline;
    align-items: baseline;
}

.self-start {
	align-self: flex-start;
}

.self-center {
	align-self: flex-center;
}

.self-end {
	align-self: flex-end;
}

.self-stretch {
	align-self: stretch;
}

.self-baseline {
    align-self: baseline;
}

.justify-start {
	-webkit-box-pack: start;
	-moz-box-pack: start;
	-o-box-pack: start;
	-ms-flex-pack: start;
	-webkit-justify-content: flex-start;
	justify-content: flex-start;
}

.justify-end {
	-webkit-box-pack: end;
	-moz-box-pack: end;
	-o-box-pack: end;
	-ms-flex-pack: end;
	-webkit-justify-content: flex-end;
	justify-content: flex-end;
}

.justify-center {
	/* -webkit-box-pack: center;
	-moz-box-pack: center;
	-o-box-pack: center;
	-ms-flex-pack: center;
	-webkit-justify-content: center; */
	justify-content: center;
}

.justify-between {
	-webkit-box-pack: justify;
	-moz-box-pack: justify;
	-o-box-pack: justify;
	-ms-flex-pack: justify;
	-webkit-justify-content: space-between;
	justify-content: space-between;
}

.justify-around {
	-ms-flex-pack: distribute;
	-webkit-justify-content: space-around;
	justify-content: space-around;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值