I can't get stuff to left and and right align on card headers via CSS. In my card header I want the the md-icon delete_forever to the right. I tried flex but did not work.
<div class="flex-container">
<div *ngFor="let item of items | async" class="flex-items-default">
<md-card (click)="test()" style="width:300px;height:250px">
<md-card-header>
<md-card-title>
<span>{{ item.name }}</span>
<span class="flex2"></span>
<span>
<button md-icon-button (click)="onDelete()">
<md-icon>delete_forever</md-icon>
</button>
</span>
</md-card-title>
<md-card-subtitle></md-card-subtitle>
</md-card-header>
<md-card-content>
{{ item.description }}
</md-card-content>
</md-card>
</div>
</div>
.flex-container {
display:flex;
flex-direction: row;
flex-wrap: wrap;
flex-flow: row wrap;
justify-content: space-between;
align-content: flex-start;
align-items: flex-start;
}
.flex2 {
flex: 1 1 auto;
}
Using Flex can be a solution, but you need to understand how to use flex properties. According to this website (and to some empirical personal experience), attritutes
align-itemsandself-alignmodify disposition on cross-axis which is, in your case,columnas long as you definedflex-direction: row.TL;DR : Change
flex-direction: rowtoflex-direction: columnand then cssself-align/align-itemswill allow you to align on horizontal axis. In your case,self-align: flex-endon your button wrapper should do the job.