Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

text-align in md-grid-tile (Angular Material) doesn't work

text-align in Angular Material <md-grid-tile> doesn't work.

<md-grid-tile>{{video.created}}</md-grid-tile>
<md-grid-tile>{{video.code</md-grid-tile>

<md-grid-tile style="text-align: left;">
   {{ video.title }}
</md-grid-tile>

<md-grid-tile>{{video.playtime}}</md-grid-tile>

I want to align text like this:

enter image description here

but text-align in <md-grid-tile> didn't work :(

How can I do it?

like image 846
rabun Avatar asked May 23 '16 08:05

rabun


4 Answers

You could simply put a span or div tag around your text inside md-grid-tile:

<md-grid-tile>
    <div class="text-inside-grid">{{ video.title }}</div>
</md-grid-tile>

and then style it:

.text-inside-grid {
  position: absolute;
  left: 5px;
}
like image 73
hatef Avatar answered Nov 05 '22 14:11

hatef


for those who have problems getting this example to work in angular2 you might need to add the ::ng-deep selector to the css for the figure

<md-grid-tile class="video-title">
    {{ video.title }}
</md-grid-tile>

css

 .video-title > ::ng-deep figure {
     justify-content: flex-start !important;
 }

*updated /deep/ to ::ng-deep because /deep/ was deprecated

like image 25
lwohlhart Avatar answered Nov 05 '22 14:11

lwohlhart


Another alternative with flex-layout (and using the latest 'mat-' prefix):

<mat-grid-tile>
    <div fxFlex fxLayoutAlign="start center">{{ video.title }}</div>
</mat-grid-tile>
like image 3
Tim Avatar answered Nov 05 '22 13:11

Tim


I did it!

<md-grid-tile>{{video.created}}</md-grid-tile>
<md-grid-tile>{{video.code</md-grid-tile>

<md-grid-tile style="text-align: left;" class="video-title">
    {{ video.title }}
</md-grid-tile>

<md-grid-tile>{{video.playtime}}</md-grid-tile>

css

.video-title > figure {
    justify-content: flex-start !important;
}
like image 1
rabun Avatar answered Nov 05 '22 13:11

rabun