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

  • Home
  • SEARCH
  • 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 9135749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:51:50+00:00 2026-06-17T08:51:50+00:00

Im setting my image src in php and controlling the styling in css. I

  • 0

Im setting my image src in php and controlling the styling in css. I have an image sprite but no matter what I do the image does not seem to clip to the area I want. Im just getting the whole image appear dispite my background-size being set to 24 by 24px.

Note that the img src has to stay in the HTML rather than moving to a bg-image in the css 🙂

A jsfiddle can be seen here
jsfiddle.net/s6UnV

Any ideas?

#swap li img {
    background-position: 0 0px;
    background-size: 24px 24px;
    display: block;
    text-indent: -10000px;
    -webkit-transition: background-position .6s;
    -moz-transition: background-position .6s;
    -o-transition: background-position .6s;
    -ms-transition: background-position .6s;
    transition: background-position .6s;
}

#swap li img:hover {
   background-position: 0 -24px;
}
  • 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-17T08:51:51+00:00Added an answer on June 17, 2026 at 8:51 am

    You shouldn’t use the tag img for sprites, you should use a div with a background-image to the one you would like to add the sprite effects.

    I updated your jsFiddle here Updated jsFiddle

    What i did was the following

    Changed the Html to

    <ul id="swap">
      <li>
        <a href="www.google.com" target="_blank">
           <div class="fb-sprite" style=" background-image:url('http://rldesign.net/Joomla3/modules/mod_social_css3/assets/glyph/facebook_hover.png')">
          </div>
        </a>
      </li>
    </ul>
    

    And added the fb-sprite class style to the css

    .fb-sprite{
        width:24px;
        height:24px;
        background-position: 0 0px;
        background-size: 24px 48px;
        display: block;
        -webkit-transition: background-position .6s;
        -moz-transition: background-position .6s;
        -o-transition: background-position .6s;
        -ms-transition: background-position .6s;
        transition: background-position .6s;
        }
    
    .fb-sprite:hover{
       background-position: 0 -24px;
        }
    

    Hope it helps

    ps: you can also use the opacity effect on this one so the facebook logo doesn’t disappear
    out of the blue, just a suggestion.

    Cheers.

    EDIT: Now you can change the url of the img programtically and the style would work. Also Updated the jsFiddle

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

Sidebar

Related Questions

Possible Duplicate: Setting image src attribute not working in Chrome When user clicks on
I have saved (Write) an image to LocalFolder not being picked up by the
I have added Images folder inside src folder in Java project. For setting top
I have the following line of javascritp $(#hero_image img).attr('src', src); to change an image.
when setting a default image for bookmarks on the home screen for iOS devices
We are setting the background image for the navigation bar and the bar button
I am setting a background image on my XAML Grid with a Uri. The
I am displaying image by setting the source of an Image element directly to
I am trying to setting up the background image of the webpage outside the
I'm setting two data values on an image using HTML5 data attributes. jQuery 1.5.2

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.