CSS - using one background image with multiple images on it

前端 未结 7 2000
情书的邮戳
情书的邮戳 2020-12-29 09:55

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 a

相关标签:
7条回答
  • 2020-12-29 10:13

    You are talking about CSS sprites, in which the background position changes on hover. Learn more here:

    http://css-tricks.com/css-sprites/

    0 讨论(0)
  • 2020-12-29 10:15

    And with CSS sprites is also possible to make e.g. menu button hover effect without waiting until second image loads. see

    0 讨论(0)
  • 2020-12-29 10:16

    Change the css property background-position.

    0 讨论(0)
  • 2020-12-29 10:27

    yes , using sprites is good for website performs because every single component on website send different http request .So, when we use sprites images the http request become less & website performance increase.That rule is also apply on css also less css files less http request. you can yourself with the help of safari web inspector.

    for more better performance download "yslow"

    0 讨论(0)
  • 2020-12-29 10:29

    It has been common for a while to put two images on one sprite sheet, but the tendency has been moving towards combining ALL of your background images on the same sprite sheet to load just one file for all of them. There's a rather good tutorial here.

    0 讨论(0)
  • 2020-12-29 10:32

    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.

    0 讨论(0)
提交回复
热议问题