Reputation: 87
I'm having problems with aligning my two col's next to eachother. I feel like I'm doing right but I guess not.... Right now the second div (the col-11) appear underneath the col-1. The col-1 have an image inside it which I want to the far left and the other col right next to it.
<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>
I'm not sure if it's because I have tables inside the div? I honestly don't know.
Upvotes: 1
Views: 87
Reputation: 465
I would do something like this:
.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/
Upvotes: 0
Reputation: 2516
The reason you are having the issue is because you are nesting the container, row and col-* the wrong way. Bootstrap suggests to use container as parent for row not inside row or col. And also, you should not nest col-* inside another col-* unless you use a row to wrap the inner col-*. Try this code to make it more clearer.
<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>
Upvotes: 1