加载失败图片加样式

一、原有样式

<img alt="暂无图片" src="1.jpg">

二、修改样式

img:after {
  content: "" "{>~<}" attr(alt);
  font-size: 16px;
  font-family: 'STKaiti';
  color: rgb(100, 100, 100);
  display: flex;
  justify-content: center;
  align-items: center;
  position: absolute;
  z-index: 2;
  top: 0;
  left: 0;
  max-height: 500px;
   100%;
  height: 100%;
  background-color: #ddd;
}

原文地址:https://www.cnblogs.com/wangyuxue/p/11321452.html