是否可以使所有弹性项目在列布局中具有相同的宽度?

时间:2018-08-30 07:15:20

标签: css css3 flexbox

column {display: flex; flex-direction: column}
column > * {border: 1px solid}
<column>
  <flex1>1234567890</flex1>
  <flex2>abc</flex2>
  <flex3>...random length...</flex3>
</column>

上面没有完成我想做的事情。

2 个答案:

答案 0 :(得分:1)

inline-flexwidth:100%用于弹性项目:

column {
  display: inline-flex;
  flex-direction: column
}

column>* {
  width: 100%;
  border:1px solid red;
}
<column>
  <flex1>1234567890</flex1>
  <flex2>abc</flex2>
  <flex3>...random length...</flex3>
</column>

答案 1 :(得分:-1)

“列布局中的宽度相同”,我想是..

.parent {
  display: flex;
}

.parent div {
  border: 1px solid red;
  flex-grow: 1;
  flex-basis: 0;
  text-align: center;
}
<div class="parent">
  <div>1234567890</div>
  <div>abc</div>
  <div>...random length...</div>
</div>