Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Material - Element overlay on images (in md-card)

I am trying to reproduce the following using angular material (that is to say, add dynamic text over an image) : text over image

I would like to use md-cards because there are convenient.

My problem is that I cannot manage to make the text overlay on the image; the text is always before or after the image.

Is playing with the position in CSS the only solution?

Thanks a lot!

like image 536
Manuel RODRIGUEZ Avatar asked Feb 07 '23 00:02

Manuel RODRIGUEZ


1 Answers

You can use a wrapper. Something like this:

HTML:

<div class="md-card-wrapper" ng-app="myapp">
  <md-card>
    <img src="http://i.imgur.com/OiqxTL1.jpg">
  </md-card>
  <span>Text over image</span>
</div>

CSS:

.md-card-wrapper {
  position: relative;
    width: 40%;
  span {
      position: absolute;
      top: 20%;
      right: 20%;
      color: white;
      font-size: 34px;
    }
}

Or you can play with my example here: http://codepen.io/anon/pen/xEpvOv

like image 71
dim0_0n Avatar answered Feb 08 '23 15:02

dim0_0n