我正在尝试在Angular中排列一些由ng-for生成的纯文本,但我似乎无法让它工作。
我现在得到的结果是:
E|
答:
D|
G|
B|
E|
-7-
21
--20-
-5
0
-19
--16-
-22-
--10
--9--
-14--
-21
-13-
--4
-19
13
-18--
-0
--15
-17-
-4--
-1-
11
--24
-2--
10
-21
23
我希望结果看起来像这样
E| -21
A| --
D|-
G| 7-
B| --
E|-
所有行都垂直对齐。
我一直在尝试flex,但我似乎想不出怎么把事情排好。
请帮帮我!
.container-1{
display:flex;
flex-direction: column;
}
.box-1{
flex:1
}
.container-2{
display:flex;
flex-direction: row;
}
<div class = "container-1">
<div class="box-1">
<div class="box-1">E |</div>
<div class="box-1">A |</div>
<div class="box-1">D |</div>
<div class="box-1">G |</div>
<div class="box-1">B |</div>
<div class="box-1">E |</div>
</div>
<div class = "container-2" *ngFor="let currentTab of tabs;">
<div *ngIf="currentTab.string == 0; then thenBlock else elseBlock"></div>
<ng-template class="box-1" #thenBlock>{{currentTab.tab}}</ng-template>
<ng-template class="box-1" #elseBlock>-</ng-template>
<div *ngIf="currentTab.string == 1; then thenBlock else elseBlock"></div>
<ng-template class="box-1" #thenBlock>{{currentTab.tab}}</ng-template>
<ng-template class="box-1" #elseBlock>-</ng-template>
<div *ngIf="currentTab.string == 2; then thenBlock else elseBlock"></div>
<ng-template class="box-1" #thenBlock>{{currentTab.tab}}</ng-template>
<ng-template class="box-1" #elseBlock>-</ng-template>
<div *ngIf="currentTab.string == 3; then thenBlock else elseBlock"></div>
<ng-template class="box-1" #thenBlock>{{currentTab.tab}}</ng-template>
<ng-template class="box-1" #elseBlock>-</ng-template>
<div *ngIf="currentTab.string == 4; then thenBlock else elseBlock"></div>
<ng-template class="box-1" #thenBlock>{{currentTab.tab}}</ng-template>
<ng-template class="box-1" #elseBlock>-</ng-template>
<div *ngIf="currentTab.string == 5; then thenBlock else elseBlock"></div>
<ng-template class="box-1" #thenBlock>{{currentTab.tab}}</ng-template>
<ng-template class="box-1" #elseBlock>-</ng-template>
</div>
</div>
https://stackoverflow.com/questions/55365978
复制相似问题