Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7888489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:50:39+00:00 2026-06-03T05:50:39+00:00

Had a few problems getting background-image displaying in Firefox, I made it work but

  • 0

Had a few problems getting background-image displaying in Firefox, I made it work but was surprised at how bloated the CSS became. It now works great, but I need to replicate base CSS code for multiple images.

Can anyone tell me if it is possible to optimise the CSS classes and minimise the amount of code. I cannot utilize the already used id’s, and class=’imga p0′ doesn’t work (where p0 just holds the background-position, becoming p1, p2, p3 .. for each image position).

Thanks in advance for any advice.

a.imga0 {background:url(../images/sprite.png) no-repeat;background-color:transparent;
  display:block;width:24px;height:24px;background-position:-288px 0;} /* tick green */
a.imga1 {background:url(../images/sprite.png) no-repeat;background-color:transparent;
  display:block;width:24px;height:24px;background-position:-312px 0;} /* cross grey */
a.imga2 { .....  and so on.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:50:40+00:00Added an answer on June 3, 2026 at 5:50 am

    Edit:
    So this should eliminate the repetition

    /* template */
    a.imag0, a.imag1, a.imag2 {
        display: block;
        width: 24px;
        height: 24px;
        background:url(../images/sprite.png) no-repeat;background-color:transparent;
    }
    
    /* specifications */
    a.imag0 {
        background-position:-288px 0;
    }
    a.imag1 {
        background-position:-312px 0;
    }
    

    For one you could create a general selector

    a {
        background:url(../images/sprite.png) no-repeat;background-color:transparent;
        display: block;
    }
    

    Which would apply the general style, such as the sprite image.

    You could also create a separate class (specify more classes with spaces)

    So for example, you could have

    <a class="imag0 spriteclass">something</a>
    <a class="imag1 spriteclass">something</a>
    <a class="imag2 spriteclass">something</a>
    

    And

    a.spriteclass {
        //again the template, such as the sprite and display type and width
    }
    

    Your second option is to list out the selectors you want the css to apply to,

    a.imag0, a.imag1, a.imag2... {
        // your general css
    }
    

    And then like above specify the specific sprite positions and details separately

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have had a few problems getting this right, so I wanted to ask
I had a few problems with my alarm that are in a another thread
I've had quite a few problems with IE6 and our website. http://www.sweetlets.com/w/solutions/click-stream/features/ At the
I've had a few questions about MEF recently, but here's the big one --
I had a similar problem a few months ago, but that was easily solved
I read about Big-O Notation from here and had few questions on calculating the
I have upgraded my grails app from 1.3.7 to 2.0.1. I had few static
Im using JSColor as colorpicker for my site, I had few issues with losing
I have been going through the core jQuery code and had a few why
Today I saw a demonstration of the episerver cms and it had a few

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.