2018-06-19发表2024-12-02更新前端几秒读完 (大约83个字)图片加载失败样式美化图片加载失败的样式是比较丑的 1<img src="http://img.png" alt="加载失败"> 可以通过添加css美化样式 1234567891011121314151617181920img{ display: inline-block; width: 100px; height: 56px; cursor: pointer; position: relative;}img:after{ position:absolute; width:100px; height: 56px; content:"" attr(alt); display: flex; justify-content: center; align-items: center; top:0; left:0; background: #eee; background-size:100%;}