flex弹性盒子布局之flex-direction和 justi

2020-02-11  本文已影响0人  CoderZb

使用display: flex;布局时,如果想让内容垂直居中的话,使用justify-content:还是使用align-items: center;是由flex-direction的值决定的。具体如下:

方向为column,那么垂直居中就为justify-content:center;

.basic_area_box {
  display: flex;
  flex-direction: column;
  justify-content:center;
  width: 100%;
  height: 88px;
}

方向为row,或者不写方向,那么垂直居中就为justify-content:center;

.basic_area_box {
  display: flex;
 /* 默认为row */
  flex-direction: row;
  align-items: center;
  width: 100%;
  height: 88px;
}
上一篇 下一篇

猜你喜欢

热点阅读