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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:36:47+00:00 2026-06-13T19:36:47+00:00

I am creating a div which contains a background image which is sized to

  • 0

I am creating a div which contains a background image which is sized to it’s container using the background-size property. Currently, this div has a separate normal and hover state. I’m trying to combine them both into a sprite but can’t quite get it to display correctly.

Here is my code:

.thumb {
width: 18.454%;
}

.thumb .image {
background-image: url('/assets/image.jpg');
background-position: -100% 0;
background-size: cover;
}

.thumb img {
width: 100%;
max-size: 204px;
}

The .thumb div gives the image a width, the .image div sets the background image, and the .thumb img is a img inside the .image div which is just to retain the image proportions when dynamically sized.

I just need to know how to change the background-position: so it works dynamically. Currently, when I use -100% 0 to move the image over, it does move, however, is at the incorrect spot in the sprite.

Thanks!

  • 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-13T19:36:49+00:00Added an answer on June 13, 2026 at 7:36 pm

    The error in sizing (about 4px off) was caused by the .image div line-height.
    This fixed the problem.

    .thumb .image {
    line-height: 0; /* FIXED */
    background-image: url('/assets/image.jpg');
    background-position: -100% 0;
    background-size: cover;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have contact list which contains (checkbox,firstname,lastname,phone). I am creating this list using html
So I am creating a container with rounded corners using the following method: div.rounded
Problem So I'm creating a simple navigation menu which contains a div of a
i am creating div using DOM Element as phototab = document.createElement('div'); phototab.setAttribute('class', 'phototab fleft');
After creating a div on the fly with this markup: $('.circuit').prepend(<div class='component' draggable='true'>TRANSISTOR</div>); It
Using jQuery in IE8, I'm creating a div with a class (ex. <div class=className></div>
I'm creating the following div using javascript, task_id is an int and person_name is
I have a div Container, and I am creating a dynamic textbox control when
I'm using fusioncharts free and creating some 3d pie charts like so... <div style=margin:0
I'm creating a webpage-head that contains a menu. The menu's background-color differs from the

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.