Do you know what is a sprite? How is it applied using CSS? What is the benefit?
Submitted by: Muhammad- 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.
BUY BUY
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>
Learn more about sprites at Smashing Magazine. Also see the Site Point article or this W3School Article.
Submitted by: Muhammad
- 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.
BUY BUY
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>
Learn more about sprites at Smashing Magazine. Also see the Site Point article or this W3School Article.
Submitted by: Muhammad
Read Online Front End Programmer Job Interview Questions And Answers
Top Front End Programmer Questions
☺ | What is variable scope? |
☺ | Tell me why do we recommend external CSS or Javascript versus inline? |
☺ | Explain what is the lazy loading? |
☺ | What is the difference between JSON and JSONP? |
☺ | HTML / HTML5 Based Front End Developer Interview Questions: |
Top Graphical User Interface (GUI) Categories
☺ | User Interface Expert Interview Questions. |
☺ | Front End Programmer Interview Questions. |
☺ | Lead Web Designer Interview Questions. |
☺ | Senior Graphics Designer Interview Questions. |
☺ | Web Designer Freelance Interview Questions. |