How to Use CSS Sprites in Fireworks and Dreamweaver
basix

How to Use CSS Sprites in Fireworks and Dreamweaver

Tutorial Details
  • Programs: Fireworks and Dreamweaver
  • Time: 15 minutes
  • Difficulty: Beginner

Ever wondered how use CSS Sprites in your own web projects? Today, Tom Green (our resident Adobe expert) is going to walk through how to create CSS sprites in Fireworks and then put them to use in Dreamweaver. If you haven’t used CSS Sprites before, or if you’re just looking for an easier way to implement them, look no further!


What Are CSS Sprites?

Put simply, a sprite is a method of using a single image as a means of storing several smaller images. For instance, take a look at the sprite that’s being used at Webdesigntuts:

When we start coding, we can simply use CSS positioning and cropping of the image to show the piece of the sprite that we want.

Why Use a CSS Sprite? Speed! Using sprites to store images will reduce the time it takes to load an entire web page… when images get re-used over and over again on multiple pages, this can mean a lot of saved time.

Sprites are best used with smaller images that get used over and over again. For instance, most of the assets discussed in an entire site can actually be reduced to a sprite such as this:

In a single sprite, we’ve already prepped the bulk of our design graphics for coding… and it’s all under 19kb! Not bad right?

To create your own sprite, just create a blank document (start out with any size, you’ll eventually crop this down to just barely fit each element on the sprite), then add in the design elements with a reasonable amount of padding between each element. Here are some additional tricks:

  • Elements that are spaced out evenly in the design should be spaced out evenly in the sprite (like the social media icons)
  • If an element is transparent (like our slider tabs), make sure it’s showing up as properly transparent in the sprite
  • Save the final sprite image as a transparent PNG-24… then you’re ready to rock and roll!

Alright, now that the basics are out of the way, Tom’s going to show us how to create these in a couple quick videos!


The Videos

These videos are recorded in HD, so feel free to hit the HD button and scale this up to fit your entire screen so that you can follow along closely.

The Fireworks Step (Creating the Sprite)


CSS Sprites in Fireworks

The Dreamweaver Step (Coding the Sprite)


CSS Sprites in Dreamweaver

That’s It!

Pretty easy right? Adding CSS Sprites to your own projects is fast and easy… which makes it a great tool to add to your bag of tricks. What’s better is that Fireworks and Dreamweaver (or any coding app) allow you to use sprites “by the numbers”, which simplifies it even further. That’s it for today – add any questions, comments, or tricks of your own below!

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • Pingback: How to Use CSS Sprites in Fireworks and Dreamweaver | Shadowtek | Hosting and Design Solutions

  • www.phpdesign.si Jure

    This is more than useful. Than you!

    Jure

  • David

    The key to the whole thing is access to precise coordinates. Fireworks makes it easy by giving you the X and Y coordinates for any object you create.

    Trying to ascertain those same coordinates in Photoshop is a pain in the rump. Especially when text is involved. I wish there were an easier way to obtain X and Y coordinates in Photoshop as I do most of my design work in that application.

    • Sean

      Have you tried the info panel? I think it comes in handy!

  • http://edwinhollen.com edwinhollen

    I would also like to share this gem: http://www.spritecow.com/

    It has helped me time and time again with sprites, saving me the headache of having to slice coordinates manually.

  • Techeese

    Great Article, I was looking for a tutorial about sprite and using Fw/Ps in making them.

    Thanks

  • Pingback: xhtml css templates – How to Use CSS Sprites in Fireworks and Dreamweaver | Webdesigntuts+ | XHTML CSS - Style sheet and html programming tutorial and guides

  • http://www.learneveryday.net arifur rahman

    Nice tutorial thanks for this. I have also a tutorial which is good for beginners.
    http://learneveryday.net/css/css-sprites-for-website-performance/

  • http://www.albertospotting.org Alberto

    Excellent!

    There is a way to make it also in Ps? I mean, like the auto-spacer

  • http://www.elimcmakin.com Eli McMakin

    There is a pretty sweet AIR application called tonttu that generate sprites. It’s very lightweight, especially in contrast to working with FW and PS.

    Check it out here: http://collamo.jp/tonttu

  • http://www.adesignlink.com Chad P

    There was one issue that I saw in the first video. You saved the image to a fireworks native png, I personally don’t recommend this if it is being used for the web because it makes a HUGE file. It is always better to save as a flattened png After you save the fireworks png because those are built for the web. Other than that this was a great basic tut on sprites.

  • Ian Rock

    I really rate Fireworks for outputting everyday web graphics and only use Photoshop when it’s absolutely necessary. (Check out Tom’s other vid’s for how Fireworks light work of everyday tasks.)

    It wasn’t specifically mentioned, but for folks new to this, if you look at the Y axis when Tom clicks on the individual icons (at around 3mins in on the first vid), it will give you the exact minus figure you need to enter into your CSS (around 5mins on the second vid).

  • http://www.hiseamarine.com marine

    The additional tricks tell me a lot.

  • Hannah

    Can you use this in Cs3?

  • http://www.360tim.com Kerstin

    Great information I have CS5 but haven’t had time to dive into all the new features since CS2 (yeah a little outdated!). This certainly helps !

  • http://www.ar-com.co.uk front end developer

    this is really simple and useful sprite image

  • http://www.sparked.biz Geoffry

    Excellent tutorial and got me into working with sprites & Fireworks. Just placed the icons on my blog: http://www.sparked.biz
    Thanks!

  • Ben Anderson

    Very helpful info here! A small site I make can easily rack up 20 image files, now I can probably lower it to 3. One for navigation, one for banners and one for buttons.

    • http://www.snaptin.com Ian Yates

      That’s great news Ben :) Though there’s really no reason for not combining your three files into one! Check out the Wdtuts+ sprite sheet for example – all you need under one roof..

  • Kyle

    I got this to work for the Hover function but I can’t get it to stay highlighted for the page I am on. I tried changing the :hover to :active but it still isn’t working. Any help? – Thanks, Kyle

  • John

    How come I can view this tut on my smart phone but not on my desk top pc?

  • Ed

    This was very helpful, this is hands down the best sprite tutorial that uses fireworks.

    I never knew it was that simple.

    thanks again.

  • Pingback: Awesome Design Resources