我正在创建一个机票预订应用程序。在客户选择位置的部分,我想在行中放置6个按钮。我正在使用List来显示我所有的按钮。如图所示,前6个按钮具有正确的位置(红色按钮)。但是蓝色按钮应该在下一行(就像我在图片上显示的那样).How我能做到吗?

myplaces-list.component.html
<div class="inventory-body" >
<h3 align="center">Wybierz miejsce</h3>
<div *ngFor="let myplace of myplaces | async" style="width: 300px;">
<myplace-details [myplace]='myplace'></myplace-details>
</div>
</div>myplaces-list.component.ts
export class MyplacesListComponent implements OnInit {
myplaces: Observable<Myplace[]>;
place_id: number;
flight: Flight = new Flight();
submitted = false;
flight_id: number;
places: Observable<Place[]>;
constructor(private myplaceService: MyplaceService, private placeService: PlaceService, private flightService: FlightService,
private router: Router, private route: ActivatedRoute) { }
ngOnInit() {
this.route.params.subscribe(params => { this.flight_id = params['flight_id']; });
this.flightService.getFlight(this.flight_id).subscribe(t => this.flight = t);
this.reloadData();
}
reloadData() {
this.myplaces = this.myplaceService.fetchEmpDeptDataInnerJoin(this.flight_id);
this.places = this.placeService.getPlacesList();
}}myplace-details.component.html -我的按钮在这里
<div *ngIf="myplace" style="position: relative; left:-30%; margin-left:10px; margin-bottom:12px">
<div>
<a href="http://localhost:4200/ticket/{{myplace.flight_id}}/{{myplace.place_id}}"
*ngIf='myplace.active' (click)='updateActive(false)' class="button btn-primary">{{myplace.location}}</a></div>
<span class="button btn-danger" *ngIf='!myplace.active' >{{myplace.location}} </span>
myplace-details.component.ts
export class MyplaceDetailsComponent implements OnInit {
@Input() myplace: Myplace;
place_id: number;
constructor(private myplaceService: MyplaceService, private listComponent: MyplacesListComponent) { }
ngOnInit() {
this.place_id = this.myplace.place_id;
}
updateActive(isActive: boolean) {
this.myplaceService.updatePlace(this.place_id,
{ location: this.myplace.location, active: isActive })
.subscribe(
data => {
console.log(data);
this.myplace = data as Myplace;
},
error => console.log(error));
}}发布于 2019-01-14 03:31:35
在一个容器中呈现列表并仅用CSS设置它的样式是困难和乏味的。
提供的平面布局的行间距不均匀(列旋转90度),我会考虑替换它或丢弃它。
我的解决方案很简单:飞机有两个座位(ABC,DEF),把它们当作容器,间隔它们添加ie。创建过道的边距。在每个容器中渲染所有座位,并使用flexbox将它们包装到新列中。Here is demo
其他选项:
display:table的https://stackoverflow.com/questions/54169950
复制相似问题