Placing button below table is not working

Asked

Viewed 279 times

1

With this HTML I cannot place the buttons below the table. I tried several ways, the current one was another attempt.

<div class="container-fluid">
    <div class="row">
        <div class="col-md-12">
            <form style="width:400px; margin: 0 auto;">
                <table class="table table-striped table-bordered">
                    <thead>
                        <tr>
                            <th>Código</th>
                            <th>Nome</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr *ngFor="let operator of dataSource">
                            <td>{{ operator.operatorId }}</td>
                            <td>{{ operator.name }}</td>
                        </tr>
                    </tbody>
                </table>                
            </form>          
      </div>
      <button type="submit" class="btn btn-primary" >Atualizar</button>
      <button type="submit" class="btn btn-primary" >Deletar</button>  
    </div>
</div>

See how the buttons appear Update and Delete inserir a descrição da imagem aqui

1 answer

1


The ideal would be to "encapsulate" the Btns within a .row as the documentation says. Besides, I don’t see why you put your <table> within a <form>

Test with this code to see if it solves. Note that I changed the tag form by a div and separated the btns into another row

NOTE: This code works both in BS3 and 4

Tip: Check by inspecting the elements or in your CSS if the first . Row with the table is not with position:absolute setate.

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" type="text/css" media="screen" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />


  <div class="container-fluid">
    <div class="row">
        <div class="col-md-12">
            <div style="width:400px; margin: 0 auto;">
                <table class="table table-striped table-bordered">
                    <thead>
                        <tr>
                            <th>Código</th>
                            <th>Nome</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr *ngFor="let operator of dataSource">
                            <td>{{ operator.operatorId }}</td>
                            <td>{{ operator.name }}</td>
                        </tr>
                    </tbody>
                </table>                
            </div>          
      </div>
    </div>
    <div class="row">
      <div class="col-md-12">
        <button type="submit" class="btn btn-primary" >Deletar</button>  
        <button type="submit" class="btn btn-primary" >Atualizar</button>
      </div>
    </div>  
</div>

  • It’s in because I’ve been running tests and that was the last position. But there’s no form on this table, it was just to test

  • @pnet ever gave an Inspection in the table to check the styles? Something else, vc "printa" this table on the page after it is rendered? Try to get the code the way it appears by giving a Ctrl+U on the page in the Browser, and not the code you have in the.html file etc. Then put the code in the question

  • Man, thanks. It was the css of the page: table {&#xA; width: 60%;&#xA; position: absolute;&#xA; left: 20%;&#xA; top: 15%;&#xA; }&#xA;&#xA; mat-row:nth-child(even){&#xA; background-color:red;&#xA; }&#xA; &#xA; mat-row:nth-child(odd){&#xA; background-color:yellow;&#xA; }

  • @pnet knew it could be this rss. So much so that he had left the "Tip:" there in the reply. But good that solved, I followed your drama there these days with these table questions and I always suspected that was it, so I had you inspect the element!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.