CSS - using one background image with multiple images on it

Deadly 提交于 2019-11-30 05:15:59

The technique is called CSS Sprites. Basically you use CSS's background-position property and fixed height or width for your element.

If your elemnts are fixed width and fixed height at the same time you can freely create a more compact image. See this site for more complex examples.

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

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

Change the css property background-position.

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"

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

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!