1.

Do You Know What Is A Sprite? How Is It Applied Using Css? What Is The Benefit?

Answer»
  • A image sprite is a collection of images put into one single image.
  • Using css positioning you can SHOW and hide different parts of the sprite depending on what you need.
  • Sprites reduces the number of http requsts thus REDUCING load time of page and bandwidth

Buy Buttons using Sprite as background:

Both buttons use the same background image. The only DIFFERECE is in the positioning.

Here is the ACTUAL background image:

And the CSS.

<style>
.orangeBuyBtn {
background: url('buyButtons-bg.gif') repeat-x 0 0;
border-color: #5B5752 #6B6B6B #808080;
border-style: solid;
border-width: 1px;
color: #FFFFFF;
cursor: pointer;
font-size: 14px;
font-weight: bold;

}
.greenBuyBtn {
background: url('buyButtons-bg.gif') repeat-x 0 -24px;
border-color: #5B5752 #6B6B6B #808080;
border-style: solid;
border-width: 1px;
color: #FFFFFF;
cursor: pointer;
font-size: 14px;
font-weight: bold;
}
</style>

 

Buy Buttons using Sprite as background:

Both buttons use the same background image. The only differece is in the positioning.

Here is the actual background image:

And the CSS.

<style>
.orangeBuyBtn {
background: url('buyButtons-bg.gif') repeat-x 0 0;
border-color: #5B5752 #6B6B6B #808080;
border-style: solid;
border-width: 1px;
color: #FFFFFF;
cursor: pointer;
font-size: 14px;
font-weight: bold;

}
.greenBuyBtn {
background: url('buyButtons-bg.gif') repeat-x 0 -24px;
border-color: #5B5752 #6B6B6B #808080;
border-style: solid;
border-width: 1px;
color: #FFFFFF;
cursor: pointer;
font-size: 14px;
font-weight: bold;
}
</style>

 



Discussion

No Comment Found