By following this elegant HTML and CSS example, I am able to showcase my initials over my photo.
While this is wonderful, I would like the initials to be displayed only if the image does not exist; if the image is present, the person's initials should not be shown.
In essence, the image should cover the initials when it exists (to hide the initials).
.profile-dot {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
align-items: center;
justify-content: center;
height: 3rem;
width: 3rem;
background-color: lightgray;
border-radius: 50%;
border: gray 2px solid;
background-size: cover;
background-position: center;
background-repeat: none;
}
.profile-dot span {
font-weight: 700;
color: #fff;
font-style: normal;
font-size: 120%;
}
<i class="profile-dot" style="background-image: url(https://i.sstatic.net/u20P2.jpg)">
<span>BM</span>
</i>
The actual initials are obtained from an Angular expression like:
<span>{{ dataItem.personInitials }}</span>
I have a hint on using figure
, but I haven't quite figured it out yet - i.e.
<figure>
<i class="profile-dot">
<img height="30" width="30" onerror="this.style.display='none'; this.className='' " src="{{ './assets/profiles/patients/' + dataItem.UID + '.jpg' }}" >
<figcaption>
<span>{{ dataItem.patientInitials }}</span>
</figcaption>
</i>
</figure>