CSS - using one background image with multiple ima

2019-02-04 18:29发布

I've observed that often the websites use only one background image which contains multiple images on it. For example, instead of using separately icons, all of the icons are put on one image and then the different parts of image are used in different section.

  • Is there any advantage to this?
  • How can this be used?

For example, for the following Stack Overflow sprite, how would I display just one of the images?

Stack Overflow Sprite Example

7条回答
2楼-- · 2019-02-04 18:59

It has the advantage that only one image needs to be loaded so that things like hover (roll-over) effects are faster. The technique is usually called "CSS sprites". Google for it.

查看更多
登录 后发表回答