img同时使用background属性设置背景图,页面出现图片加载失败的问题
<img class="imgStyle" width="24px" height="22px" src="" alt="">
.imgStyle { display:block; width: 24px; height:22px; background: url(../img/aa.png) no-repeat center center; background-size: contain; }
【问题描述】此时需要的图片可以加载成功,但同时页面会出现"裂图"的效果,原因是src属性为空
【解决方案】尽量避免使用img的background属性,建议改成span标签