<ul class="image-list">
<li>
<img src="https://miro.medium.com/fit/c/128/128/1*TyRLQdZO7NdPATwSeut8gg.png">
</li>
<li>
<img src="https://miro.medium.com/xxx.jpg" alt='Log of Medium' onerror="this.classList.add('error');">
</li>
<li>
<img src="https://miro.medium.com/fit/c/128/128/1*mXOVdfMwS0IEcjPXiikJkg.png">
</li>
</ul>
.image-list {
display: flex;
flex-direction: row;
list-style: none;
}
ul li img {
width: 128px;
height: 128px;
object-fit: cover;
}
img.error {
display: inline-block;
transform: scale(1);
content: "";
color: transparent;
}
img.error::before {
content: "";
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: #f5f5f5
url("https://cdn-images-1.medium.com/max/1600/1*we8wfyztsdo12e2Cww6oVA.jpeg")
no-repeat center / 100% 100%;
}
img.error::after {
content: attr(alt);
position: absolute;
left: 0;
bottom: 0;
width: 100%;
line-height: 2;
background-color: rgba(0, 0, 0, 0.5);
color: white;
font-size: 12px;
text-align: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.