Using Angular 2, I was trying to partly show a cover image by using
img[md-card-image] {
hidden: overflow;
max-heigth: 160px;
}
However, Angular decides that it boxes the image inside during the overflow. I cannot seem to figure out how to get the image fill the whole top of the card.
Edit 1
If I do not use the above css, and instead change the div which wraps my cover image to margin-bottom: -50%;
which moves the text up on top of the image; however, in this case, I cannot set a background to the content on the card. for the part of the text that runs over the image.
After days of trying different things, I finally came up with a solution. I had to remove the md-card-image
and manually do it with divs. I guess the material design css is messing with it causing the issue when you add the hidden: overflow
to the container.
Here's what it looks like:
My styling for the material card:
md-card {
padding: 0px;
margin: 20px;
.cover-wrapper {
width: 100%;
height: 160px;
.cover-image {
top: 0;
left: 0;
width: 100%;
height: 100%;
background-size: cover;
}
}
.cover-footer {
background-color: rgba(255, 255, 255, 0.5);
margin: -50px 0px 0px 0px;
padding: 10px;
div[md-card-title] {
font-weight: bold;
width: 100%;
font-size: $font-size-large;
}
}
}
The html for the material card:
<md-card class="mat-elevation-z2" mat-whiteframe="8" fxLayout="column">
<div class="cover-wrapper" fxFlex>
<div class="cover-image" [style.background-image]="'url(' + _cover + ')' | safeStyle"></div>
</div>
<div class="cover-footer" fxFlex>
<div md-card-title fxFlex>{{ _title }}</div>
</div>
<md-card-content>
<div [innerHtml]="_text | safeHtml" id="markdown"></div>
</md-card-content>
</md-card>