【问题标题】:Align items to left while flex direction is row-reverse in Flex在 Flex 中,当 flex 方向为 row-reverse 时,将项目向左对齐
【发布时间】:2019-03-09 15:07:09
【问题描述】:

我想在左对齐的情况下以相反的顺序显示项目

这是我的工作小提琴,但项目向右对齐。

#main {
    width: 400px;
    height: 400px;
    border: 1px solid #c3c3c3;
    display: flex;
    flex-direction: row-reverse;
    align-items: flex-start;
}

#main div {
    width: 50px;
    height: 50px;
}
<div id="main">
  <div style="background-color:coral;">A</div>
  <div style="background-color:lightblue;">B</div>
  <div style="background-color:khaki;">C</div>
  <div style="background-color:pink;">D</div>
  <div style="background-color:lightgrey;">E</div>
  <div style="background-color:lightgreen;">F</div>
</div>

谁能帮帮我,提前谢谢。

【问题讨论】:

  • #main { justify-content: flex-end; } 是你想要的。

标签: css flexbox alignment direction


【解决方案1】:

您需要指定justify-content: flex-end;

#main {
  width: 400px;
  height: 400px;
  border: 1px solid #c3c3c3;
  display: flex;
  flex-direction: row-reverse;
  align-items: flex-start;
  justify-content: flex-end;
}

#main div {
  width: 50px;
  height: 50px;
}
<div id="main">
  <div style="background-color:coral;">A</div>
  <div style="background-color:lightblue;">B</div>
  <div style="background-color:khaki;">C</div>
  <div style="background-color:pink;">D</div>
  <div style="background-color:lightgrey;">E</div>
  <div style="background-color:lightgreen;">F</div>
</div>

【讨论】:

    猜你喜欢
    • 2016-11-19
    • 1970-01-01
    • 2019-01-16
    • 2019-05-11
    • 1970-01-01
    • 2016-02-19
    • 1970-01-01
    • 2021-10-07
    • 2022-11-21
    相关资源
    最近更新 更多