Using sprites with IMG tag?

后端 未结 6 1440
余生分开走
余生分开走 2020-11-29 23:26

I understand how to use sprites, however, isn\'t a \"src\" attribute required for IMG tags? I could always use a SPAN or other tag and set the background/width/etc but it wo

6条回答
  •  遥遥无期
    2020-11-30 00:23

    I use a 1x1 transparent gif (so called spacer) for the src. then set the background image for that img tag with the corresponding bg position. this way you're utilizing the speed of sprites and keeping the semantic of your code (you can still use the alt attribute)

提交回复
热议问题