-3

I need to create ion-card as shown below. I have tried many ways. But no luck yet. Any clue?

Note: It has 2 images. top one and small book cover.

Here is the sample of stackblitz

This is what I need:

enter image description here

.html

<ion-card class="card-margin">
    <img class="contentPicture" [src]="data?.image" />

    <ion-card-content>
        <ion-item class="book-cover">
            <ion-thumbnail item-left class="thumbnail">
                <img [src]="data?.image2">
            </ion-thumbnail>
        </ion-item>
        <ion-item class="book-details">
            <h2>From book:
                <span>My book</span>
            </h2>
            <h2>Publisher:
                <span>My publisher</span>
            </h2>
        </ion-item>
    </ion-card-content>
</ion-card>
Sampath
  • 63,341
  • 64
  • 307
  • 441

2 Answers2

2

My attempt can be found here.

Set styles in .book-cover class:

.book-cover{
  top: -50px;
  z-index: 2;
  background: transparent;
}

Note: You may have to edit the image's alpha to remove the whitespace in the image itself if you have any.

For the name section, I suggest using ion-row and ion-col instead of ion-item as the latter takes up the entire row.

<ion-card-content>
    <ion-grid>
      <ion-row>
            <ion-col col-2 class="book-cover">
                <ion-thumbnail item-left class="thumbnail">
                    <img [src]="data?.image2">
                </ion-thumbnail>
            </ion-col>
            <ion-col class="book-details">
                <h2>From book:
                    <span>My book</span>
                </h2>
                <h2>Publisher:
                    <span>My publisher</span>
                </h2>
            </ion-col>
      </ion-row>
    <ion-grid>
    </ion-card-content>
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
0

Use position: relative to the main image and position: absolute to the book image here I did sample code

.bg-image {
  position: relative;
  
}
.book {
  position: absolute;
  top: 250px;
}
.text {
  position: absolute;
  left: 180px;
  
}
<div class="bg-image">
<img src="https://i.imgur.com/U4Oadyu.png">
</div>
<div class="book">
<img src="https://i.imgur.com/r7uK5St.jpg">
</div>
<div class="text">
<p>Text Here</p>
</div>
Mehraj Khan
  • 927
  • 6
  • 17