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 8717665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:21:12+00:00 2026-06-13T06:21:12+00:00

I am trying to condense my CSS a bit but I’ve hit a snag

  • 0

I am trying to condense my CSS a bit but I’ve hit a snag with this. I am using CSS backgrounds to swap out some text links for images with a simple rollever effect. The images are all the same height (apart from 1 in each div, the first one) so I’m trying to handle them all with 2 CSS rules, one for all of them and one for the bigger first link. Here’s an example:

<div id="div1" class="common">
    <a id="link0" class="big" href="link"></a>

    <a id="link1" href="link"></a>

    <a id="link2" href="link"></a>

    <a class="class1" href="link"></a>
    <a id="link3" href="link"></a>
</div>
<div id="div2" class="common">
    ...
</div>

And so on. I’m using the following CSS:

.class1
{
    background:url(images/pdf.png);
    display:block;
    height:38px;
    width:39px;
}

.common a:hover
{
    background-position:0 -38px;
}

.common a.big:hover
{
    background-position:0 -117px;
}

#div1
{
    background:url(images/bg1.png);
}

#link0
{
    background:url(images/big1.png);
    display:block;
    height:117px;
    width:964px;
}

#link1
{
    background:url(images/1_1.png);
    display:block;
    height:38px;
    width:425px;
}

#link2
{
    background:url(images/1_2.png);
    display:block;
    height:38px;
    width:425px;
}

#link3
{
    background:url(images/1_3.png);
    display:block;
    height:38px;
    width:425px;
}

The problem is that this doesn’t seem to apply the background-position rule to the links with ID’s (#link0, #link1 etc) but it does select the one link which does not have an ID (.class1). If I change the .common a:hover selector to #div1 a:hover if works but then I have to have a rule for each div, which is the opposite of what I’m trying to do.

What am I doing wrong? I cannot use JQuery, it has to be pure CSS.

  • 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-13T06:21:13+00:00Added an answer on June 13, 2026 at 6:21 am

    For this you have to define background-image instead of background in your ID link0 ,link1 etc. Write like this:

    #link0
    {
        background-image:url(images/big1.png);
    }
    
    #link1
    {
        background-image:url(images/1_1.png);
    }
    
    #link2
    {
        background-image:url(images/1_2.png);
    }
    
    #link3
    {
        background-image:url(images/1_3.png);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

trying to figure out why this is happening - I have an input text
Trying to find some information on this but am unable to get any results
Trying to figure out how I can do this properly. The print_r looks like
Trying to execute a Powershell cmdlet from a MVC 3 Controller using impersonation but
I'm trying to condense/improve/optimize this code cleaned = stringwithslashes cleaned = cleaned.replace(\\n, \n) cleaned
Using the Sinatra library, I'm trying to condense two functions that display HTML code
I'm trying to condense this by wrapping it in a loop: if (pos.X +
I'm trying to format some jquery options, in this case for the autocomplete plugin.
I'm trying to map two objects to each other using a ManyToMany association, but
In order to condense my code I am trying to make one of my

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.