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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:58:59+00:00 2026-05-25T15:58:59+00:00

What is preferred way to add discount tags over some product image using css?

  • 0

What is preferred way to add discount tags over some product image using css?

My current implementation is this http://jsfiddle.net/ANtfG/7/

Html

<ul>   
    <li class="save_money">
        <img src="http://lorempixum.com/200/200/food" />
        <span class="twenty-percent"  /></span>
    </li>   
</ul>

CSS

.save_money{position:relative;float:left;margin:15px;background:yellow;display:inline}
.save_money img{position:absolute;}
.twenty-percent{background:url(http://canadianneighborpharmacy.net/images/cnp/discount_20.png);position:absolute; left:170px; top:-2px; width:45px; height:45px}

I want to improve these two restriction in my current implementation or tell me the better way to achieve this

  1. How to align discount tag to right, not using left:170px? right:0
    doesn’t work. and width of product images can be changed sometime
    then left:170px will not be flexible to width.
  2. I’m using a Blank span element in mark-up I would like to know if
    there is another way to do it. Why I used span over <img> because I
    have different tags for 20%, 30%, 40% discount. SO i thought instead
    using <img> it would begood to add a span with classes like
    .twenty-percent, .thirty-percent, .forty-prcent
  • 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-25T15:59:00+00:00Added an answer on May 25, 2026 at 3:59 pm

    How to align discount tag to right, not using left:170px? right:0
    doesn’t work. and width of product images can be changed sometime then
    left:170px will not be flexible to width.

    Use right: -15px. That way, when you adjust the width, the “discount tag” will still be positioned correctly. position: absolute on the img must be removed, because with it the li has no width or height. I added display: block to remove the ~4px of yellow space underneath the img caused by the img being display: inline.

    See: http://jsfiddle.net/thirtydot/ANtfG/9/

    I’m using a Blank span element in mark-up I would like to know if
    there is another way to do it. Why I used span over because I
    have different tags for 20%, 30%, 40% discount. SO i thought instead
    using it would begood to add a span with classes like
    .twenty-percent, .thirty-percent, .forty-prcent

    That’s fine. The only other option would to omit the span and use :before – but of course, that won’t work in older browsers such as IE7 (and it won’t quite work in IE8 due to an IE8 bug).

    See: http://jsfiddle.net/thirtydot/ANtfG/11/


    You should fix this:

    <span class="twenty-percent"  /></span>
    

    to this:

    <span class="twenty-percent"></span>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When loading images using Loader, what's the preferred way to add the image to
I'd like to know which is the preferred way to add records to a
Is there a preferred way to handle animation when using Flex -- For instance,
What is the preferred way using the CF 3.5 to get get data from
Is there a preferred way to go about this? The app in question is
What is the preferred way to remove spaces from a string in C++? I
What is the preferred way to open a URL from a thick client application
What would be your preferred way to concatenate strings from a sequence such that
What is the preferred way to insert strings that can contain both single and
What is your preferred way of keeping controls centered on its parent when 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.