布局
PC更侧重兼容,移动端更侧重布局。
从div+css至bootstrap到flexbox
弹性布局是css3推出的针对移动端的经典的布局形式,是对CSS2的补充
弹性容器的方向
-
display: flex;
布局形式 -
flex-direction: row;
定义主轴方向,如果此行缺省,则默认为row -
row
行,横向从左往右排列 -
row-reverse:
从右到左的水平方向为主轴 -
column
列,纵向从上往下排列 -
column-reverse:
从下到上的垂直方向为主轴 -
justify-content:
弹性项目在主轴main-axis线上的对齐方式 ,flex-start左,flex-end右,center中,space-etween散列(左右紧靠边缘),space-around散列(平均,左右不靠边缘) -
align-items:
在容器中与主轴垂直方向的对齐方式。(主轴是横向则此为垂直方向对齐方式,主轴是纵向则为模向对齐方式)
.container {
height: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
padding: 200rpx 0;
box-sizing: border-box;
}
flex 数字形式
flex:1;平分布局
.container {
display: flex;
flex:1;
}