Adobe
Products
Acrobat
Creative Cloud
Creative Suite
Digital Marketing Suite
Digital Publishing Suite
Elements
Photoshop
Touch Apps
Student and Teacher Editions
More products
Solutions
Digital marketing
Digital media
Education
Financial services
Government
Web Experience Management
More solutions
Learning Help Downloads Company
Buy
Home use for personal and home office
Education for students, educators, and staff
Business for small and medium businesses
Licensing programs for businesses, schools, and government
Special offers
Search
 
Info Sign in
Welcome,
My cart
My orders My Adobe
My Adobe
My orders
My information
My preferences
My products and services
Sign out
Why sign in? Sign in to manage your account and access trial downloads, product extensions, community areas, and more.
Adobe
Products Sections Buy   Search  
Solutions Company
Help Learning
Sign in Sign out My orders My Adobe
Preorder Estimated Availability Date. Your credit card will not be charged until the product is shipped. Estimated availability date is subject to change. Preorder Estimated Availability Date. Your credit card will not be charged until the product is ready to download. Estimated availability date is subject to change.
Qty:
Purchase requires verification of academic eligibility
Subtotal
Review and Checkout
Adobe Developer Connection / Fireworks Developer Center /

Working with CSS sprites in Fireworks CS6

by Priyanka C. Herur

Priyanka C. Herur

Content

  • Exporting CSS sprites from Fireworks
  • Using CSS sprites in a web page
  • Creating custom optimization preset
  • Where to go from here

Created

7 May 2012

Page tools

Share on Facebook
Share on Twitter
Share on LinkedIn
Bookmark
Print
CSS Fireworks

Requirements

Prerequisite knowledge

Basic familiarity working with Fireworks is required. Prior experience building websites with CSS is also recommended.

User level

Intermediate

Required products

  • Fireworks (Download trial)

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.

Exporting CSS sprites from Fireworks

Look at the following design prototype created using Fireworks.

Figure 1. A Fireworks page
Figure 1. A Fireworks page

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:

  • Creating slices
  • Generating CSS sprites
  • Using CSS sprites in a web page

Creating slices

The CSS Sprites Export feature in Fireworks CS6 makes use of a familiar technique -- creating slices. The CSS sprites are generated from the slices.

  1. Select the Slice tool from the Tools panel.
Figure 2. The Slice tool
Figure 2. The Slice tool
  1. Create slices in the Fireworks object.
    Alternatively, you can create slices using the context menu.
Figure 3. Creating slices context menu
Figure 3. Creating slices context menu

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.

  1. Select the slices from the Fireworks source file from which you want to generate the sprite image.
    You can also select slices from multiple pages.
  2. Right-click and select Export CSS Sprite from the context menu.
Figure 4. The Export CSS Sprite context menu
Figure 4. The Export CSS Sprite context menu

Alternatively, to export CSS sprites, select File > Export. Then, select CSS Sprites.

Figure 5. The Export option
Figure 5. The Export option

The Export dialog box appears. You can customize the sprite image settings and the CSS style sheet in the "Export" dialog box.

  1. Change the sprite image settings and CSS style sheet settings in the Export dialog box.
Figure 6. The Export dialog box
Figure 6. The Export dialog box

The Export dialog box options

  • Pages: Allows you to export slices from the selected pages, all pages, or current page.
    Note: Slices in the Master page and shared layers are included only once in the sprite image.
  • Selected Slices Only: If selected, exports slices that are selected in single or multiple pages.
  • Current State Only: If selected, exports the slices in the current state in case the pages have multiple states. For example, if a button symbol has multiple states, only the "Up" state graphic of the button is exported.
  • Save As: Allows you to provide the filename of the sprite image that is being exported.
  • Options: Provides the CSS Sprites Export Options dialog box.
  1. Click Options in the Export dialog box. In the CSS Sprites Export option, specify the CSS selector, CSS selector name prefix and suffix, orientation of the exported sprites, and the file type of the exported sprites.
Figure 7. The CSS Sprite Export Options
Figure 7. The CSS Sprite Export Options

The CSS sprites export options

  • CSS Selector: For each one of the slices, a class or ID is generated.
    Note: Selector consists of the displacement values. The selector name is the name of the slice along with prefix and suffix. To reference a particular graphic of the sprite image in the HTML page, use the slice name. A base class with the class name as the filename is generated. It contains the global property - CSS background. Use this property with the selector while referencing the graphic inside the sprite image in an HTML page.
  • Prefix: Provide the prefix of the CSS selector name.
  • Suffix: Provide the suffix of the CSS selector name.
    A preview of the class or id along with the prefix and suffix is provided.
Figure 8. A preview of the class or id along with the prefix and suffix.
Figure 8. A preview of the class or id along with the prefix and suffix.
  • Padding: Provides the spacing between individual graphics in the sprite image.
  • Layout: Specifies the orientation of the exported sprite image graphics. It can be horizontal, vertical, or grid.
Figure 9. Specifiy the orientation of the exported sprite image graphics.
Figure 9. Specifiy the orientation of the exported sprite image graphics.
  • Optimization Preset: Specifies the exported sprite image file type. You can also create a customized optimization preset. For more details, see Creating custom optimization preset.
Figure 10. Specify an optimization preset.
Figure 10. Specify an optimization preset.

Using CSS sprites in a web page

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:

Figure 11. Exported sprite image.
Figure 11. Exported sprite image.

Exporting CSS sprites from Fireworks also generates a CSS file. The exported CSS file consists of the following:

  • The base class as shown below. It consists of the background property pointing to the sprite image location. The URL has to be modified if the image file is moved to a different location. See the URL provided in the code.
  • .pluralist_homepage{ background:url("pluralist_homepage.jpg") top left no-repeat; }
  • Classes/IDs are generated for each of the slices based on user preference. It consists of the displacement values to be used to render the graphic inside the sprite image. The base class name along with the respective class names generated for Fireworks slices should be used to render the slice graphic in the HTML web page. Pseudo classes such as hover, active and visited are generated for button symbols with multiple states.
.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:

  1. Launch Dreamweaver.
  2. Open an existing web page or create a blank HTML page.
    The basic layout of the web page for the design prototype in Fireworks is created in Dreamweaver. We'll see how to render the graphics of the sprite image in this webpage.
Figure 12. Using sprite images in a web page – 1.
Figure 12. Using sprite images in a web page – 1.

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.

  1. In the Code view, add the link to point to the CSS style sheet exported from Fireworks, as shown below:
<link href="assets/css/pluralist_homepage.css" rel="stylesheet" type="text/css" />
  1. To include individual graphic of the sprites, include the base class name and the respective class or ID names in the tag. The selectors and selector names are the preferences selected during the export in Fireworks. The selector names include slice name and prefix or suffix if you have provided while generating.

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:

Figure 13. Using sprite images in a web page – 2.
Figure 13. Using sprite images in a web page – 2.

Creating custom optimization preset

Fireworks provides a default set of optimization presets. You can also create an optimization preset of your own.

  1. Click File > Image Preview.
  2. In the Image Preview dialog box, select the optimization settings.
  3. Click Add and provide the name for the optimization settings.
Figure 14. Creating a custom optimization preset.
Figure 14. Creating a custom optimization preset.

Where to go from here

For more about CSS in Fireworks, see Extracting CSS properties from Fireworks design objects. For more Fireworks learning resources, visit the Fireworks Developer Center.

More Like This

  • Extracting CSS properties from design objects in Fireworks
  • Extracting CSS properties from design objects in Fireworks using the CSS3 Mobile Pack

Tutorials & Samples

Tutorials

  • Creating jQuery Mobile website themes in Fireworks
  • Extracting CSS properties from Fireworks design objects
  • Working with CSS sprites in Fireworks CS6

Samples

  • Twitter Trends
  • Flex 4.5 reference applications
  • Mobile Trader Flex app on Android Market

Fireworks Forum

More
04/19/2012 How to center multiple text in a button
04/22/2012 What exactly needs to be done to have my browser output text into a path that the user cannot type..
04/21/2012 Website Ranking
04/20/2012 Link problem with Fireworks CS5 - net::ERR_FILE_NOT_FOUND

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

Products

  • Acrobat
  • Creative Cloud
  • Creative Suite
  • Digital Marketing Suite
  • Digital Publishing Suite
  • Elements
  • Mobile Apps
  • Photoshop
  • Touch Apps
  • Student and Teacher Editions

Solutions

  • Digital marketing
  • Digital media
  • Web Experience Management

Industries

  • Education
  • Financial services
  • Government

Help

  • Product help centers
  • Orders and returns
  • Downloading and installing
  • My Adobe

Learning

  • Adobe Developer Connection
  • Adobe TV
  • Training and certification
  • Forums
  • Design Center

Ways to buy

  • For personal and home office
  • For students, educators, and staff
  • For small and medium businesses
  • For businesses, schools, and government
  • Special offers

Downloads

  • Adobe Reader
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player

Company

  • News room
  • Partner programs
  • Corporate social responsibility
  • Career opportunities
  • Investor Relations
  • Events
  • Legal
  • Security
  • Contact Adobe
Choose your region United States (Change)
Choose your region Close

North America

Europe, Middle East and Africa

Asia Pacific

  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States

South America

  • Brasil
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Česká republika
  • Danmark
  • Eastern Europe - English
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • 台灣

Southeast Asia

  • Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam - English

Copyright © 2012 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy Policy and Cookies (Updated)

Ad Choices

Reviewed by TRUSTe: site privacy statement