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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:45:33+00:00 2026-06-15T16:45:33+00:00

I am trying to get css sprites to work. My image consists of two

  • 0

I am trying to get css sprites to work. My image consists of two parts. The left part is black and the rigt part is white.

The code below shows the white part of the image. If i change the -40px value to 0 in #item0, it displays the both the black and the white part.

I cannot get it to just show the black part of the image. Can you spot what i am doing wrong?

<style type="text/css">
    #menu-left {            
        width: 200px;
        background-color: #73b2d6;

    }

    #navlist li {
        list-style: none;
        padding-left: 10px;
        width: 190px;
    }

    #navlist a {
        width: 150px;
        height: 44px;
        padding-left: 40px;
        padding-top: 20px;
        display: block;
        width: 100px;
    }

    #item0 {
        background: url('http://www.fabian.dk/all.png') -40px 7px no-repeat;
    }
</style>

<div id="menu-left">
    <ul id="navlist">
        <li id="item0"><a href="#">link 1</a></li>
    </ul>
</div>
  • 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-15T16:45:34+00:00Added an answer on June 15, 2026 at 4:45 pm

    Unfortunately it cannot be done with the DOM-structure you have, in a way that I can think of. Since the li-element is larger than the background, it is not possible to cut of the right part of an image like that.

    The easiest thing I can think of is to add an additional element within your li element, with a fixed size, and apply the background to that element instead of the entire li.

    HTML:

    <div id="menu-left">
        <ul id="navlist">
            <li id="item0"><div></div><a href="#">link 1</a></li>
        </ul>
    </div>​
    

    CSS:

    #navlist li div {
        background: url('http://www.fabian.dk/all.png') 0 7px no-repeat;
        width: 40px;
        height: 40px;
        float: left;
    }​
    

    Working example

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

Sidebar

Related Questions

I'm trying to get this css layout to work with IE7 and I'm a
I am trying to work with CSS Sprites for my webapp. Here is my
I'm trying to get the css value of the background-image of some div, but
I'm trying to get a CSS-only drop-down menu working. It largely does work except
http://jsfiddle.net/xfCE8/3/ I've been trying to get less CSS to work, but with no luck,
Image Sprites , by themselves, are not evil; however, trying to get these to
I’m trying to get the CSS pseudo :nth-child(n) function to work in Internet Explorer
This button is before CSS Sprites <input type=image src=/images/search-button.png value= id=search-button> I'm trying to
I'm pulling my hair out here trying to get CSS to position only a
I have been trying to get yui-css grid system to make a three column

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.