SlideShare une entreprise Scribd logo
1  sur  9
Télécharger pour lire hors ligne
CSS Sprite




             By http://www.psd2htmlwordpress.com
What is Image Sprite
• The idea behind CSS sprite is to consolidate multiple
  images into one sprite and then selectively display
  portions of this sprite with positioning.
• It has its origin in Computer Graphics
• Sprites are the master image from which individual
  images can later be pulled for website design as needed
  by the code.
• Displayed as a static or dynamic background image
Advantages of CSS Sprite
• A web page with many images can take a long time to
  load and generates multiple server requests. Using
  image sprites will reduce the number of server requests
  and save bandwidth.
• CSS sprites reduce HTTP requests
• CSS sprites are commonly used, particularly for
  navigation (such as for hover effects), icons and buttons
Disadvantages of CSS Sprites
• Maintenance : Changing the size of an icon in a sprite,
  also need to adjust the CSS to fix the positioning,
  padding, or dimensions of the element

• Accessibility : While using background images we
  remove the image tag from the markup, which could
  reduce the meaningfulness of the content
Where are CSS Sprites Used
• CSS sprites are mainly used in a pixel based design.

• CSS sprites are used to keep the design maintainable
  and easy to update.
How to create a navigation list using the
                sprite image
• The following code shows the creation of navigation list
  #navlist{position:relative;}
  #navlist li{margin:0;padding:0;list-style:none;position:absolute;top:0;}
  #navlist li, #navlist a{height:44px;display:block;}

  #home{left:0px;width:46px;}
  #home{background:url('img_navsprites.gif') 0 0;}

  #prev{left:63px;width:43px;}
  #prev{background:url('img_navsprites.gif') -47px 0;}

  #next{left:129px;width:43px;}
  #next{background:url('img_navsprites.gif') -91px 0;}
How to add hover effect using image sprites

• The following lines of code can be used to add
  hover effect

  #home a:hover{background: url('img_navsprites_hover.gif') 0 -45px;}
  #prev a:hover{background: url('img_navsprites_hover.gif') -47px -
  45px;}
  #next a:hover{background: url('img_navsprites_hover.gif') -91px -
  45px;}
Contact Info
PSD to HTML Wordpress
www.psd2htmlwordpress.com
Y8,Block EP,Sec – v
Salt Lake, Kol – 700091,India
PH : +913340200838
Email:info@psd2htmlwordpress.com
Thank
 You

Contenu connexe

Tendances

How to create your own Dojo theme
How to create your own Dojo themeHow to create your own Dojo theme
How to create your own Dojo themeYiwei Ma
 
An Introduction to CSS Frameworks
An Introduction to CSS FrameworksAn Introduction to CSS Frameworks
An Introduction to CSS FrameworksAdrian Westlake
 
Why are we using Sass to create Grid Frameworks?
Why are we using Sass to create Grid Frameworks?Why are we using Sass to create Grid Frameworks?
Why are we using Sass to create Grid Frameworks?sharjeet
 
SilverStripe Meetup 07/06/2011
SilverStripe Meetup 07/06/2011SilverStripe Meetup 07/06/2011
SilverStripe Meetup 07/06/2011GPMD Ltd
 
Choosing your animation adventure - Generate NYC 2018
Choosing your animation adventure  - Generate NYC 2018Choosing your animation adventure  - Generate NYC 2018
Choosing your animation adventure - Generate NYC 2018Val Head
 

Tendances (9)

Mobilize drupal
Mobilize drupalMobilize drupal
Mobilize drupal
 
Front end-performance
Front end-performanceFront end-performance
Front end-performance
 
Before Going Vector
Before Going VectorBefore Going Vector
Before Going Vector
 
How to create your own Dojo theme
How to create your own Dojo themeHow to create your own Dojo theme
How to create your own Dojo theme
 
Compass n Sass
Compass n SassCompass n Sass
Compass n Sass
 
An Introduction to CSS Frameworks
An Introduction to CSS FrameworksAn Introduction to CSS Frameworks
An Introduction to CSS Frameworks
 
Why are we using Sass to create Grid Frameworks?
Why are we using Sass to create Grid Frameworks?Why are we using Sass to create Grid Frameworks?
Why are we using Sass to create Grid Frameworks?
 
SilverStripe Meetup 07/06/2011
SilverStripe Meetup 07/06/2011SilverStripe Meetup 07/06/2011
SilverStripe Meetup 07/06/2011
 
Choosing your animation adventure - Generate NYC 2018
Choosing your animation adventure  - Generate NYC 2018Choosing your animation adventure  - Generate NYC 2018
Choosing your animation adventure - Generate NYC 2018
 

Similaire à Css sprite

Website trends 2012 presentation
Website trends 2012 presentationWebsite trends 2012 presentation
Website trends 2012 presentationFresh_Egg
 
Simply Responsive CSS3
Simply Responsive CSS3Simply Responsive CSS3
Simply Responsive CSS3Denise Jacobs
 
CSS3: Ripe and Ready to Respond
CSS3: Ripe and Ready to RespondCSS3: Ripe and Ready to Respond
CSS3: Ripe and Ready to RespondDenise Jacobs
 
Lect-4-Responsive-Web-06032024-082044am.pptx
Lect-4-Responsive-Web-06032024-082044am.pptxLect-4-Responsive-Web-06032024-082044am.pptx
Lect-4-Responsive-Web-06032024-082044am.pptxzainm7032
 
Web programming css
Web programming cssWeb programming css
Web programming cssUma mohan
 
"Responsive Web Design: Clever Tips and Techniques". Vitaly Friedman, Smashin...
"Responsive Web Design: Clever Tips and Techniques". Vitaly Friedman, Smashin..."Responsive Web Design: Clever Tips and Techniques". Vitaly Friedman, Smashin...
"Responsive Web Design: Clever Tips and Techniques". Vitaly Friedman, Smashin...Yandex
 
Adobe MAX 2008: HTML/CSS + Fireworks
Adobe MAX 2008: HTML/CSS + FireworksAdobe MAX 2008: HTML/CSS + Fireworks
Adobe MAX 2008: HTML/CSS + FireworksNathan Smith
 
CSS3: Ripe and Ready
CSS3: Ripe and ReadyCSS3: Ripe and Ready
CSS3: Ripe and ReadyDenise Jacobs
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4Erin M. Kidwell
 
Organize Your Website With Advanced CSS Tricks
Organize Your Website With Advanced CSS TricksOrganize Your Website With Advanced CSS Tricks
Organize Your Website With Advanced CSS TricksAndolasoft Inc
 
Responsive Web Design: Clever Tips and Techniques
Responsive Web Design: Clever Tips and TechniquesResponsive Web Design: Clever Tips and Techniques
Responsive Web Design: Clever Tips and TechniquesVitaly Friedman
 

Similaire à Css sprite (20)

Website trends 2012 presentation
Website trends 2012 presentationWebsite trends 2012 presentation
Website trends 2012 presentation
 
Simply Responsive CSS3
Simply Responsive CSS3Simply Responsive CSS3
Simply Responsive CSS3
 
Http _css-tricks
Http  _css-tricksHttp  _css-tricks
Http _css-tricks
 
Intro to CSS3
Intro to CSS3Intro to CSS3
Intro to CSS3
 
CSS3: Ripe and Ready to Respond
CSS3: Ripe and Ready to RespondCSS3: Ripe and Ready to Respond
CSS3: Ripe and Ready to Respond
 
Lect-4-Responsive-Web-06032024-082044am.pptx
Lect-4-Responsive-Web-06032024-082044am.pptxLect-4-Responsive-Web-06032024-082044am.pptx
Lect-4-Responsive-Web-06032024-082044am.pptx
 
Web programming css
Web programming cssWeb programming css
Web programming css
 
Css group
Css groupCss group
Css group
 
Css group
Css groupCss group
Css group
 
Css group
Css groupCss group
Css group
 
"Responsive Web Design: Clever Tips and Techniques". Vitaly Friedman, Smashin...
"Responsive Web Design: Clever Tips and Techniques". Vitaly Friedman, Smashin..."Responsive Web Design: Clever Tips and Techniques". Vitaly Friedman, Smashin...
"Responsive Web Design: Clever Tips and Techniques". Vitaly Friedman, Smashin...
 
Adobe MAX 2008: HTML/CSS + Fireworks
Adobe MAX 2008: HTML/CSS + FireworksAdobe MAX 2008: HTML/CSS + Fireworks
Adobe MAX 2008: HTML/CSS + Fireworks
 
CSS3: Ripe and Ready
CSS3: Ripe and ReadyCSS3: Ripe and Ready
CSS3: Ripe and Ready
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
 
Css3
Css3Css3
Css3
 
CSS and CSS3
CSS and CSS3CSS and CSS3
CSS and CSS3
 
Sass compass
Sass compassSass compass
Sass compass
 
Organize Your Website With Advanced CSS Tricks
Organize Your Website With Advanced CSS TricksOrganize Your Website With Advanced CSS Tricks
Organize Your Website With Advanced CSS Tricks
 
SVG 101
SVG 101SVG 101
SVG 101
 
Responsive Web Design: Clever Tips and Techniques
Responsive Web Design: Clever Tips and TechniquesResponsive Web Design: Clever Tips and Techniques
Responsive Web Design: Clever Tips and Techniques
 

Css sprite

  • 1. CSS Sprite By http://www.psd2htmlwordpress.com
  • 2. What is Image Sprite • The idea behind CSS sprite is to consolidate multiple images into one sprite and then selectively display portions of this sprite with positioning. • It has its origin in Computer Graphics • Sprites are the master image from which individual images can later be pulled for website design as needed by the code. • Displayed as a static or dynamic background image
  • 3. Advantages of CSS Sprite • A web page with many images can take a long time to load and generates multiple server requests. Using image sprites will reduce the number of server requests and save bandwidth. • CSS sprites reduce HTTP requests • CSS sprites are commonly used, particularly for navigation (such as for hover effects), icons and buttons
  • 4. Disadvantages of CSS Sprites • Maintenance : Changing the size of an icon in a sprite, also need to adjust the CSS to fix the positioning, padding, or dimensions of the element • Accessibility : While using background images we remove the image tag from the markup, which could reduce the meaningfulness of the content
  • 5. Where are CSS Sprites Used • CSS sprites are mainly used in a pixel based design. • CSS sprites are used to keep the design maintainable and easy to update.
  • 6. How to create a navigation list using the sprite image • The following code shows the creation of navigation list #navlist{position:relative;} #navlist li{margin:0;padding:0;list-style:none;position:absolute;top:0;} #navlist li, #navlist a{height:44px;display:block;} #home{left:0px;width:46px;} #home{background:url('img_navsprites.gif') 0 0;} #prev{left:63px;width:43px;} #prev{background:url('img_navsprites.gif') -47px 0;} #next{left:129px;width:43px;} #next{background:url('img_navsprites.gif') -91px 0;}
  • 7. How to add hover effect using image sprites • The following lines of code can be used to add hover effect #home a:hover{background: url('img_navsprites_hover.gif') 0 -45px;} #prev a:hover{background: url('img_navsprites_hover.gif') -47px - 45px;} #next a:hover{background: url('img_navsprites_hover.gif') -91px - 45px;}
  • 8. Contact Info PSD to HTML Wordpress www.psd2htmlwordpress.com Y8,Block EP,Sec – v Salt Lake, Kol – 700091,India PH : +913340200838 Email:info@psd2htmlwordpress.com