我遇到了将我的两个col对齐的问题。 我觉得我做得对,但我猜不是......现在第二个div(col-11)出现在col-1下面。 col-1里面有一个图像,我想在最左边,另一个在它旁边。
<div class="container col-md-12 wm-body">
<div class="row" style="margin: 0px;">
<div class="col-md-12" style="padding-left: 0px;">
<div class="container-fluid" style="padding: 0;">
<div class="row wm-card" style="margin: 15px 0 0 0; padding: 0px;">
<div class="col-md-1">
<img src="../../../assets/img/trip.svg" class="icon">
</div>
<div class="col-md-11">
<table *ngIf="trip" class="table-sm wm-table-drive-orders" style="width: 60%;">
<div>
<tbody class="col-md-12">
<tr *ngIf="firstNode">
<td style="padding-bottom: 0px;">
<b>Datum</b>
</td>
<td style="padding-bottom: 0px;">
<p>{{ tripHelper.getActualTimeStringFromNode(firstNode) }}</p>
</td>
<td style="padding-bottom: 0px;">
<i class="fa" aria-hidden="true" [ngClass]="tripHelper.getState(firstNode)" [ngStyle]="{'color':
tripHelper.getState(firstNode, true)}"></i>
</td>
<td style="padding-bottom: 0px;">
<p>{{ geographyHelper.getAddressString(trip.addresses[0]) }}, {{ geographyHelper.getPostalAreaString(trip.addresses[0])}}
</p>
</td>
<td style="padding-bottom: 0px;">
<!--<ng-container *ngIf="trip.people">
<p>{{peopleHelper.getPeopleNameString(trip.people)}} </p>
</ng-container>-->
<b>Tidskrav</b>
</td>
<td style="padding-bottom: 0px;">
<!-- TODO: Add seat description -->
<b>Status</b>
</td>
</tr>
</tbody>
</div>
</table>
<table>
<tbody class="col-md-12">
<tr *ngIf="lastNode">
<td style="padding-top: 0px;">
<p>{{tripHelper.getDateString(trip)}}</p>
</td>
<td style="padding-top: 0px;">
<i class="fa" aria-hidden="true" [ngClass]="tripHelper.getState(lastNode)" [ngStyle]="{'color':
tripHelper.getState(lastNode, true)}"></i>
</td>
<td style="padding-top: 0px;">
<p>{{ geographyHelper.getAddressString(trip.addresses[1]) }}, {{ geographyHelper.getPostalAreaString(trip.addresses[1])}}
</p>
</td>
<td style="padding-top: 0px;">
<!--<ng-container *ngIf="trip.people">
<p>{{peopleHelper.getPeopleNameString(trip.people)}} </p>
</ng-container>-->
<p>-</p>
</td>
<td style="padding-top: 0px;">
<!-- TODO: Add seat description -->
<p>{{tripHelper.getStateString(trip)}}</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
我不确定是不是因为我在div里面有桌子?老实说,我不知道。
答案 0 :(得分:1)
您遇到问题的原因是因为您正在以错误的方式嵌套容器,行和列。 Bootstrap建议使用容器作为行的父级而不是行或列。而且,除非使用一行来包裹内部col- *,否则不应将col- *嵌套在另一个col- *中。尝试使用此代码可以使其更清晰。
<div class="container wm-body">
<div class="wm-card" style="margin: 15px 0 0 0; padding: 0px;">
<div class="row" style="margin: 0px;">
<div class="col-md-1">
<img src="../../../assets/img/trip.svg" class="icon">
</div>
<div class="col-md-11">
<table *ngIf="trip" class="table-sm wm-table-drive-orders" style="width: 60%;">
<div>
<tbody class="col-md-12">
<tr *ngIf="firstNode">
<td style="padding-bottom: 0px;">
<b>Datum</b>
</td>
<td style="padding-bottom: 0px;">
<p>{{ tripHelper.getActualTimeStringFromNode(firstNode) }}</p>
</td>
<td style="padding-bottom: 0px;">
<i class="fa" aria-hidden="true" [ngClass]="tripHelper.getState(firstNode)" [ngStyle]="{'color':tripHelper.getState(firstNode, true)}"></i></td>
<td style="padding-bottom: 0px;">
<p>{{ geographyHelper.getAddressString(trip.addresses[0]) }}, {{ geographyHelper.getPostalAreaString(trip.addresses[0])}}
</p>
</td>
<td style="padding-bottom: 0px;">
<!--<ng-container *ngIf="trip.people">
<p>{{peopleHelper.getPeopleNameString(trip.people)}} </p>
</ng-container>-->
<b>Tidskrav</b>
</td>
<td style="padding-bottom: 0px;">
<!-- TODO: Add seat description -->
<b>Status</b>
</td>
</tr>
</tbody>
</div>
</table>
<table>
<tbody class="col-md-12">
<tr *ngIf="lastNode">
<td style="padding-top: 0px;">
<p>{{tripHelper.getDateString(trip)}}</p>
</td>
<td style="padding-top: 0px;">
<i class="fa" aria-hidden="true" [ngClass]="tripHelper.getState(lastNode)" [ngStyle]="{'color':
tripHelper.getState(lastNode, true)}"></i>
</td>
<td style="padding-top: 0px;">
<p>{{ geographyHelper.getAddressString(trip.addresses[1]) }}, {{ geographyHelper.getPostalAreaString(trip.addresses[1])}}
</p>
</td>
<td style="padding-top: 0px;">
<!--<ng-container *ngIf="trip.people">
<p>{{peopleHelper.getPeopleNameString(trip.people)}} </p>
</ng-container>-->
<p>-</p>
</td>
<td style="padding-top: 0px;">
<!-- TODO: Add seat description -->
<p>{{tripHelper.getStateString(trip)}}</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
答案 1 :(得分:0)
我会做这样的事情:
.wm-table-drive-orders td {padding-bottom: 0px;}
.add-on-table td {padding-top: 0px;}
/* COMMON CLASSES */
.no-padding-left {padding-left: 0px;}
.no-padding-right {}
.no-side-padding {}
.no-padding {padding: 0;}
.no-margin {margin: 0;}
.width-40 {}
.width-50 {}
.width-60 {width: 60%;}
/* DEBUG */
.row {background: red;}
.col-md-1 {background: green;}
.col-md-11 {background: blue;}
table td {word-break: break-all;}
<div class="container wm-body">
<div class="row no-margin">
<div class="col-md-12">
<div class="row wm-card no-padding" style="margin: 15px 0 0 0;">
<div class="col-md-1">
<img src="../../../assets/img/trip.svg" class="icon">
</div>
<div class="col-md-11">
<table *ngIf="trip" class="table-sm wm-table-drive-orders width-60">
<tbody class="col-md-12">
<tr *ngIf="firstNode">
<td>
<b>Datum</b>
</td>
<td>
<p>{{ tripHelper.getActualTimeStringFromNode(firstNode) }}</p>
</td>
<td>
<i class="fa" aria-hidden="true" [ngClass]="tripHelper.getState(firstNode)" [ngStyle]="{'color':tripHelper.getState(firstNode, true)}"></i>
</td>
<td>
<p>{{ geographyHelper.getAddressString(trip.addresses[0]) }}, {{ geographyHelper.getPostalAreaString(trip.addresses[0])}}
</p>
</td>
<td>
<!--<ng-container *ngIf="trip.people">
<p>{{peopleHelper.getPeopleNameString(trip.people)}} </p>
</ng-container>-->
<b>Tidskrav</b>
</td>
<td>
<!-- TODO: Add seat description -->
<b>Status</b>
</td>
</tr>
</tbody>
</table>
<table class="add-on-table">
<tbody class="col-md-12">
<tr *ngIf="lastNode">
<td>
<p>{{tripHelper.getDateString(trip)}}</p>
</td>
<td>
<i class="fa" aria-hidden="true" [ngClass]="tripHelper.getState(lastNode)" [ngStyle]="{'color':
tripHelper.getState(lastNode, true)}"></i>
</td>
<td>
<p>{{ geographyHelper.getAddressString(trip.addresses[1]) }}, {{ geographyHelper.getPostalAreaString(trip.addresses[1])}}
</p>
</td>
<td>
<!--<ng-container *ngIf="trip.people">
<p>{{peopleHelper.getPeopleNameString(trip.people)}} </p>
</ng-container>-->
<p>-</p>
</td>
<td>
<!-- TODO: Add seat description -->
<p>{{tripHelper.getStateString(trip)}}</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
JSFiddle:https://jsfiddle.net/aq9Laaew/7925/