Make 2 buttons inside a table cell be next to each other

前端 未结 5 519
北海茫月
北海茫月 2021-01-11 15:37

I have the following code :

      
        
相关标签:
5条回答
  • 2021-01-11 15:47

    What you need is just css display inline code, which can be use to format your button form { display: inline; }

    this displays an element as an inline element like span

    0 讨论(0)
  • 2021-01-11 15:53

    Please see how to use <table> tag inside in <td> and get all button in line.

    <table>
            <td>
               <table>
                   <tr>
                       <td>
                          <button class="btn btn-primary btn-xs">Add</button>
                        </td>
                       <td> 
                          <button class="btn btn-primary btn-xs">Edit</button>
                      </td>
                      <td> 
                          <button class="btn btn-primary btn-xs">View</button>
                      </td>
                   </tr>
               </table>
            </td>
     </table>

    0 讨论(0)
  • 2021-01-11 15:55

    If you're using Bootstrap, try using classes like "pull-left". This will float both of the buttons left and bring them inline. Also check to be sure nothing is overriding the current display attribute.

    <div class="pull-left">...</div>
    <div class="pull-right">...</div>
    
    0 讨论(0)
  • 2021-01-11 16:05

    Did you tried display: inline-block;? However that seems unnecessary because two buttons in the same table cell will appear on the same line.

    table,
    td,
    tr {
      border: 1px solid black;
      border-collapse: collapse;
    }
    <table>
      <tr>
        <td>
          <button>Button1</button>
          <button>Button2</button>
        </td>
      </tr>
    </table>

    0 讨论(0)
  • 2021-01-11 16:07

    If I add that code in a snippet the buttons are next to each other, so it's hard to reproduce:

    <table>
      <tr>
        <td>
          <button class="btn btn-primary btn-xs" ng-click="r.changeView('requests/edit/' + request.id)">
            <i class="fa fa-pencil-square-o"></i>Button1
          </button>
          <button class="btn btn-primary btn-xs" ng-click="r.changeView('requests/edit/' + request.id)">
            <i class="fa fa-step-backward"></i>
            <i class="fa fa-step-forward"></i>Button2
          </button>
        </td>
      </tr>
    </table>

    The buttons are already displayed as inline-block. Maybe the table isn't wide enough; if so, You could try <td style='white-space: nowrap'>.

    0 讨论(0)
提交回复
热议问题