7 May 2012
Basic familiarity working with Fireworks is required. Prior experience building websites with CSS is also recommended.
Intermediate
In this article, you'll learn how to work with Adobe Fireworks CS6 to generate CSS Sprites. A sprite image consists of multiple graphics that are combined together to form a single image. Each one of the graphics in the sprite image can be rendered separately in an HTML web page using the data provided in the CSS style sheet.
One of the techniques used to render images in the web page is web slices. In this technique, user has to create slices for the required graphic in the web page design and use these slices as individual images in the web page. This method adversely affects the response time of the page since loading all the images in a web page requires multiple HTTP requests. This affects the load-time performance of the website.
One of the widely used techniques to render images in the web page without hampering the load time of the website is the CSS sprites technique. In this technique, individual images to be rendered in the web page can be stitched together as a single sprite image. Individual parts of the sprite image can be rendered as required using CSS. This would reduce the network latency by fetching a single image instead of multiple images. Using the CSS sprites technique, we can improve the load-time performance significantly. This is particularly helpful on handheld devices that have limited bandwidth.
CSS Sprites can be generated from the design prototype created in Fireworks. Slices can be created on objects that need to be used as images. On CSS sprite export, a sprite image, where the slices in the Fireworks page are stitched together as a single image, is generated. A CSS file that contains the information regarding the displacement values to render individual graphic of the sprite image is also generated.
Look at the following design prototype created using Fireworks.
The Fireworks page displayed above consists of multiple images. This article explains how to export the images highlighted in the header section as CSS sprites and then use it in a web page. The process involves the following:
The CSS Sprites Export feature in Fireworks CS6 makes use of a familiar technique -- creating slices. The CSS sprites are generated from the slices.
Note: The slice name is the name of the selector. It is used in the HTML page to render the image beneath the slice in Fireworks source file.
After creating the necessary slices, generate CSS sprites for selected slices or all the slices.
Alternatively, to export CSS sprites, select File > Export. Then, select CSS Sprites.
The Export dialog box appears. You can customize the sprite image settings and the CSS style sheet in the "Export" dialog box.
The Export dialog box options
The CSS sprites export options
At this point, we have exported CSS sprites from Fireworks. Exporting as CSS Sprites from Fireworks generates a sprite image and a CSS file. The sprite image that is exported is provided below:
Exporting CSS sprites from Fireworks also generates a CSS file. The exported CSS file consists of the following:
.FW_shop_Pluralist{ width:19px; height:18px; background-position:-10px -10px; }
.FW_shop_Pluralist:hover{ width: 19px; height: 18px; background-position:-39px -10px; }
.FW_designers_Pluralist{ width: 21px; height: 16px; background-position:-10px -38px; }
.FW_designers_Pluralist:hover{ width: 21px; height: 16px; background-position:-41px -388px; }
.FW_blog_Pluralist{ width:16px; height:15px; background-position:-10px -64px; }
.FW_blog_Pluralist:hover{ width: 16px; height: 15px; background-position:-36px -64px; }
.FW_stores_Pluralist{ width:13px; height:15px; background-position:-10px -89px; }
.FW_stores_Pluralist:hover{ width: 13px; height: 15px; background-position:-33px -89px; }
To use the CSS sprites in a web page, do the following:
In the above screen, let us include the sprites in the header section highlighted in the Design view. The corresponding code for the header is highlighted in the Code view.
<link href="assets/css/pluralist_homepage.css" rel="stylesheet" type="text/css" />
For example, to include the "shop" icon in the header, provide the class names in the tag as shown below:
<li class="pluralist_homepage FW_shop_Pluralist"> SHOP </li>
The HTML page with icons for the four elements in the header is provided below:
Fireworks provides a default set of optimization presets. You can also create an optimization preset of your own.
For more about CSS in Fireworks, see Extracting CSS properties from Fireworks design objects. For more Fireworks learning resources, visit the Fireworks Developer Center.
Fireworks Forum |
More |
Fireworks Cookbooks |
More |
| 09/07/2011 | How do I use FXG XML markup in Shape subclasses? |
|---|---|
| 10/15/2010 | Flex4 Dotted Line |
| 06/25/2010 | ComboBox that uses a NativeMenu (Air API) |
| 05/21/2010 | Localizing a Creative Suite 5 extension |