React Native 从底部增长Flexbox项目

r3i60tvu  于 2023-02-05  发布在  React
关注(0)|答案(2)|浏览(82)

我不敢相信我会问这个问题,因为它一定很简单。但我在react-native工作,必须使用flexbox,我认为这一点,但我是开放的建议。

***我意识到react native将使用视图而不是Div,但这个问题实际上是关于flexbox的,我将无法使用网格。虽然我也很好奇如何在网格中完成

使用以下标记:

<div class="container">
  <div class="icon">icon button number one</div>
  <div class="icon">an even larger text with stuff in it
two</div>
  <div class="icon">a large bit of text three</div>
</div>

和CSS:

.container {
  display: flex;
  background-color: yellow;
  width: 500px;
  flex-direction: row-reverse;
  flex-wrap: wrap;
  border: 3px black solid;
}
.icon {
  padding: 10px;
  background-color: black;
  color: white;
  margin: 10px;
}

我希望能够动态地从底部增长这个按钮的“列表”。
就像这样,集装箱里的潜水员排成一排

<an even larger text with stuff in it two> <icon button number one>
                                        <a large bit of text three>

但我想让它们像这样排好:

<a large bit of text three>
<an even larger text with stuff in it two> <icon button number one>

当项目最终将被动态添加时,如何让它们自下而上增长?
https://codepen.io/sias/pen/ZEjmXBj

hrirmatl

hrirmatl1#

我希望这是你想要的 Package 反向只是颠倒和开始和结束交换

.container {
  display: flex;
  justify-content:flex-end;
  background-color: yellow;
  width: 500px;
  flex-wrap: wrap-reverse;
  border: 3px black solid;
  
}
.icon {
  padding: 10px;
  background-color: black;
  color: white;
  margin: 10px;
}
qqrboqgw

qqrboqgw2#

像这样?

body, html {
  height: 100%;
}
.container {
  display: flex;
  justify-content: flex-end;
  width: 500px;
  flex-flow: column;
  height: 100%;
  outline: 3px black dotted;

}
.icon {
  margin-top: 12px;
  background-color: black;
  color: white;

}
<div class="container">
  <div class="icon">icon button number one</div>
  <div class="icon">an even larger text with stuff in it
two</div>
  <div class="icon">a large bit of text three</div>
</div>

相关问题