将项目与ngFor向左对齐



我有一个div,我想在其中动态添加一些输入,因为输入应该是一个具有格式的数字,所以我添加justify-content-end类从左开始。HTML:

<div class='row justify-content-end'>
<ng-container *ngFor='let input of dashAndInputCount; let i = index'>
<button (click)='addDashAndInput(i)'> - </button>
<div class='col-2' style='padding-top: 2.2rem !important;'>
<input type='number'></input>
</div>
<div class='col-1 ax-text-center'>
<p>
ــ
</p>
</div>
</ng-container>
</div>

TS:

addDashAndInput(i) {
this.dashAndInputCount.push(1);
}

现在的问题是,当我添加一个项目时,该项目的添加方向是错误的。例如,如果我在行中添加1、2、3、4,我将得到4、3、2、1。我该怎么解决这个问题?

justify content属性依赖于display:flex您应该将display:flex添加到justify内容的最终类

.justify-content-end{
display: flex;
justify-content: end;
}

在容器中包含d-flex类。使用d-flex,元素的行为类似于块元素,并根据flexbox模型布局其内容。

最新更新