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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:28:41+00:00 2026-05-31T05:28:41+00:00

I have a rollover image that makes use of a large background image that

  • 0

I have a rollover image that makes use of a large background image that keep changing it’s background-position based on which area the mouse is over.

$(this).mouseover(function() {
    $('#' + id).css('background-position','0 -' + thisoffset + 'px');
})

The problem is that I am trying to make the image scalable. With normal <img> tags, I could just specify width/height and it will scale, but there is no such property for background-image, so what solution do you use?

CSS3 has a background-size property, but not all web users have a CSS3 compliant browser…

=======================

Clunky, but I got it to work with GGG’s answer using this layout

<div id="outer"
     style="width:300px;height:330px;position:relative;overflow:hidden;">
<img id="image"
     src="url.gif"
     style="width:100%;height:auto;position:absolute;left:0;bottom:0;z-order:-99;" />
<img id="areamap"
     src="transparent.gif"
     style="width:100%;height:100%;position:absolute;"
     usemap="#map" />

This way, I only need to specify the container width once (div). The image scales to the width (100%) and the height auto-calculates using the same scale. The transparent image which is mapped fills the container entirely.

  • 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-05-31T05:28:41+00:00Added an answer on May 31, 2026 at 5:28 am

    You answered your own question, it’s the CSS background-size property. You could also use transform. All of this stuff is CSS3, there was no way to do it prior to that.

    What you can do is use a normal img, scaled, and change its position within a div that clips it.

    The HTML will look something like this:

    <div class="map-outer"><img src="map-sprite.png"></div>
    

    The CSS will look something like this:

    .map-outer { height: 500px; width: 500px; overflow: hidden; position: relative; }
    .map-outer img { height: 5500px; width: 500px; position: absolute; }
    

    Now you can set the top and left CSS properties on the img in the same way that you were setting the background-position property before.

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

Sidebar

Related Questions

I'm using the CSS based rollover trick that switches the background position of the
I have the following code a.rollover { background-image: url('sprite.jpg'); display: block; width: 191px; height:
I have a JQuery script which acts as a simple image rollover with a
I have 3 images and have a function so that on mouse rollover they
I have a complicated background image with a lot of small regions that need
i have the following code that does a image rollover on pictureboxes located inside
I have a question on rollover effects using JavaScript. I have read that image
I have multiple DIVs containing an image in each. When I rollover these DIVs,
have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:
I have the following CSS where an image 'vote_up' is a background image. I'd

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.