简体   繁体   中英

How to text align right with datatable

<table id="table-DataView-Ceft-History" class="table table-bordered v-table">
  <thead>
    <tr>
      <th style="width:auto;">Date</th>
      <th style="width:auto;">MBSL Account No</th>
      <th style="width:auto;">Reference No</th>
      <th style="width:auto;">Amount(LKR)</th>
      <th style="width:auto;">Reason</th>
      <th style="width:auto;">Third Party Acc No</th>
      <th style="width:auto;">Transfer status</th>
      <th style="width:auto;">Target Bank</th>
      <th style="width:auto;">Transfer By</th>
    </tr>
  </thead>
</table>

Using jQuery , it can be done by css method

$('#table-DataView-Ceft-History thead th').css('text-align', 'right');

OR, we can use text-align: right; css property for right alignment of text in th tags

 th { text-align: right; }
 <table id="table-DataView-Ceft-History" class="table table-bordered v-table"> <thead> <tr> <th style="width:auto;">Date</th> <th style="width:auto;">MBSL Account No</th> <th style="width:auto;">Reference No</th> <th style="width:auto;">Amount(LKR)</th> <th style="width:auto;">Reason</th> <th style="width:auto;">Third Party Acc No</th> <th style="width:auto;">Transfer status</th> <th style="width:auto;">Target Bank</th> <th style="width:auto;">Transfer By</th> </tr> </thead> </table>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM