Align button at end of table

1

I have this table

<div class="container">
    <div class="row">
        <div class="col-md-12">
        <table class="table table-striped table-bordered">
         <caption>Lista de Tipo de Campos</caption>
            <thead class="thead-dark">
                <tr>
                    <th>Nome</th>
                </tr>
            </thead>
            <tbody>
                <tr *ngFor="let typefield of dataSource">
                    <div *ngIf="typefield.edit!=true">
                        <td class="col-md-10">{{ typefield.name }}</td>
                        <td class="col-md-1">
                                <fa *ngIf="checkEdit()" name="pencil" (click)="initEditTypeField(typefield)"></fa>
                            </td>
                            <td class="col-md-1">
                                <fa *ngIf="checkEdit()" name="times" (click)="onDelete(typefield)"></fa>
                            </td>
                    </div>
                    <form [formGroup]="createForm" *ngIf="typefield.edit === true">
                            <td class="col-md-6"> {{ typefield.typefieldId}}<input formControlName="id" type="hidden" class="col-md-1"></td>
                            <td> <input formControlName="name" type="text"></td>
                            <td class="col-md-1">
                                <fa name="save" (click)="onUpdate()"></fa>
                            </td>
                            <td class="col-md-1">
                                <fa name="ban" (click)="typefield.edit = null; initDefaultForm();"></fa>
                            </td>
                    </form>
                </tr>
            </tbody>

        </table>
        <div>
            <input type="button" class="btn btn-success pull-right" value="+">
        </div>
      </div>
</div>
</div>

At the end of it has a value="+" button; How do I make this button aligned to the end of the table on the right.

    
asked by anonymous 29.07.2018 / 15:28

4 answers

1

Without entering into the merits of the semantics that are wrong (as it was quoted), put div within caption and use class float-right :

<caption>
   Lista de Tipo de Campos
   <div class="float-right">
      <input type="button" class="btn btn-success pull-right" value="+">
   </div>
</caption>

See:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><linkrel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script><divclass="container">
   <div class="row">
      <div class="col-md-12">
         <table class="table table-striped table-bordered">
            <caption>
               Lista de Tipo de Campos
               <div class="float-right">
                  <input type="button" class="btn btn-success pull-right" value="+">
               </div>
            </caption>
            <thead class="thead-dark">
               <tr>
                  <th>Nome</th>
               </tr>
            </thead>
            <tbody>
               <tr *ngFor="let typefield of dataSource">
                  <div *ngIf="typefield.edit!=true">
                     <td class="col-md-10">{{ typefield.name }}</td>
                     <td class="col-md-1">
                        <fa *ngIf="checkEdit()" name="pencil" (click)="initEditTypeField(typefield)"></fa>
                     </td>
                     <td class="col-md-1">
                        <fa *ngIf="checkEdit()" name="times" (click)="onDelete(typefield)"></fa>
                     </td>
                  </div>
                  <form [formGroup]="createForm" *ngIf="typefield.edit === true">
                     <td class="col-md-6"> {{ typefield.typefieldId}}<input formControlName="id" type="hidden" class="col-md-1"></td>
                     <td> <input formControlName="name" type="text"></td>
                     <td class="col-md-1">
                        <fa name="save" (click)="onUpdate()"></fa>
                     </td>
                     <td class="col-md-1">
                        <fa name="ban" (click)="typefield.edit = null; initDefaultForm();"></fa>
                     </td>
                  </form>
               </tr>
            </tbody>
         </table>
      </div>
   </div>
</div>
    
29.07.2018 / 21:08
1

You can use this

<div class="container">
    <div class="row">
        <div class="col-md-12">
        <table class="table table-striped table-bordered" style="float:left">
         <caption>Lista de Tipo de Campos</caption>
            <thead class="thead-dark">
                <tr>
                    <th>Nome</th>
                </tr>
            </thead>
            <tbody>
                <tr *ngFor="let typefield of dataSource">
                    <div *ngIf="typefield.edit!=true">
                        <td class="col-md-10">{{ typefield.name }}</td>
                        <td class="col-md-1">
                                <fa *ngIf="checkEdit()" name="pencil" (click)="initEditTypeField(typefield)"></fa>
                            </td>
                            <td class="col-md-1">
                                <fa *ngIf="checkEdit()" name="times" (click)="onDelete(typefield)"></fa>
                            </td>
                    </div>
                    <form [formGroup]="createForm" *ngIf="typefield.edit === true">
                            <td class="col-md-6"> {{ typefield.typefieldId}}<input formControlName="id" type="hidden" class="col-md-1"></td>
                            <td> <input formControlName="name" type="text"></td>
                            <td class="col-md-1">
                                <fa name="save" (click)="onUpdate()"></fa>
                            </td>
                            <td class="col-md-1">
                                <fa name="ban" (click)="typefield.edit = null; initDefaultForm();"></fa>
                            </td>
												
                    </form>
                </tr>
            </tbody>

        </table>
		<div style="float: right; width:  100%;">
		<button style="float: right;">+</button>
		</div>
        <div>
    
29.07.2018 / 15:45
0

If you want to align according to the size of the table, you can use the tfoot of the table and put the button there, with right alignment in td see example:

table {
  border-collapse: collapse;
  border: 1px solid black;
  width: 100px;
}

table td {
  border: 1px solid black;
  padding: 5px
}
table tfoot td {
  text-align: right;
}
<table>
  <tbody>
    <tr>
      <td>um</td>
      <td>dois</td>
      <td>três</td>
    </tr>
    
  </tbody>
  <tfoot>
    <tr>
      <td colspan="3">
        <input type="button" class="btn btn-success pull-right" value="+">
      </td>
    </tr>
  </tfoot>
</table>
    
29.07.2018 / 17:11
-1

test this:)

class="btn btn-success pull-right col-md-offset-2"
    
27.09.2018 / 22:14