Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Material 2 Datatable headers not aligned right

I have set the styles for header cell and cell to be aligned right but headers are not aligned only the cell text

Here is a link to a sample

I have added

.mat-cell, .mat-header-cell {
    text-align: right;
}
like image 471
pantonis Avatar asked Sep 19 '26 22:09

pantonis


2 Answers

text-align: right doesn't work with display:flex element, and here you're trying to applying text-align property on mat-header-cell' elements mat-sort-header-container class. You could use below to fix your issue.

::ng-deep .mat-header-cell .mat-sort-header-container {
    justify-content: flex-end;
}

Forked Stackblitz

like image 107
Pankaj Parkar Avatar answered Sep 21 '26 13:09

Pankaj Parkar


This worked for me. I added the following to the css:

.mat-column-columnname {
    text-align: right;
    justify-content: flex-end;
}

And changed the location of the sort arrow to before the label:

<th mat-header-cell mat-sort-header arrowPosition='before' *matHeaderCellDef>
like image 22
tmjac2 Avatar answered Sep 21 '26 14:09

tmjac2



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!