Vertical align in bootstrap table

后端 未结 7 1991
萌比男神i
萌比男神i 2020-12-23 02:54

I am trying to display a table with 4 columns, one of which is an image. Below is the snapshot:-\"enter

相关标签:
7条回答
  • 2020-12-23 03:00

    Based on what you have provided your CSS selector is not specific enough to override the CSS rules defined by Bootstrap.

    Try this:

    .table > tbody > tr > td {
         vertical-align: middle;
    }
    

    In Boostrap 4, this can be achieved with the .align-middle Vertical Alignment utility class.

    <td class="align-middle">Text</td>
    
    0 讨论(0)
  • 2020-12-23 03:01

    As of Bootstrap 4 this is now much easier using the included utilities instead of custom CSS. You simply have to add the class align-middle to the td-element:

    <table>
      <tbody>
        <tr>
          <td class="align-baseline">baseline</td>
          <td class="align-top">top</td>
          <td class="align-middle">middle</td>
          <td class="align-bottom">bottom</td>
          <td class="align-text-top">text-top</td>
          <td class="align-text-bottom">text-bottom</td>
        </tr>
      </tbody>
    </table>
    
    0 讨论(0)
  • 2020-12-23 03:11

    vetrical-align: middle did not work for me for some reason (and it was being applied). I used this:

    table.vertical-align > tbody > tr > td {
      display: flex;
      align-items: center;
    }
    
    0 讨论(0)
  • 2020-12-23 03:17

    For me <td class="align-middle" >${element.imie}</td> works. I'm using Bootstrap v4.0.0-beta .

    0 讨论(0)
  • 2020-12-23 03:17

    The following appears to work:

    table td {
      vertical-align: middle !important;
    }
    

    You can apply to a specific table as well like so:

    #some_table td {
      vertical-align: middle !important;
    }
    
    0 讨论(0)
  • 2020-12-23 03:18

    SCSS

    .table-vcenter {
        td,
        th {
            vertical-align: middle;
        }
    }
    

    use

    <table class="table table-vcenter">
    </table>
    
    0 讨论(0)
提交回复
热议问题