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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:14:15+00:00 2026-06-17T12:14:15+00:00

I am developing an eCommerce shop where on over 100 category pages, the thumbnails

  • 0

I am developing an eCommerce shop where on over 100 category pages, the thumbnails are not the same size and/or proportion. I need to center all images with the class Thumbnail within its div. I have already added a relative position to the item as well as a margin to center.

Can someone help me write a quick jquery that will add get the width of each image with the class thumbnail and add it to each img tag?

.thumbnail {
position: relative;
margin: 0 auto;
}

Perhaps something like this is a start. I need to search the document for each image with a certain class, then get the width of each image and add it as css.

$(document).find(".Thumbnail").css({
width: $(this).width()
});
  • 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-17T12:14:16+00:00Added an answer on June 17, 2026 at 12:14 pm

    I can only guess, but as I understand, your Markup looks a like this:

    ...
    
    <div class='product'>
      <img src='image.jpg' class='thumbnail' />
    </div>
    
    <div class='product'>
      <img src='image2.jpg' class='thumbnail' />
    </div>
    
    ...
    

    if you now want to equalize the thumbnail-width to the parent simply use CSS:

    .product {
     margin: 0px;
     width: 200px; // just as an example
     height: 200px; // just as an example
     float: left; // just as an example
     margin: 0px 7px 7px 0px; // just as an example
    }
    
    .thumbnail {
     width: 100%;
    }
    

    the use of jQuery for this need is a waste of performance but you could do it like this:

    $(".thumbnail").each(function() {
     $(this).css({
          "width" : $(this).parent().width()+"px"
      });
    }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently developing a large ecommerce website and I also need to develop
I am developing a Ecommerce website by using version Magento 1.6. I need to
I am developing an eCommerce website which contains around 2000-3000 products(no.can be increase in
I'm new to magento. Currently i'm developing two ecommerce sites using multi-store option in
I am currently developing a little ecommerce application to help me get to grips
Developing a project of mine I realize I have a need for some level
Developing a C# .NET 2.0 WinForm Application. Need the application to close and restart
I am developing an ecommerce app that is using the UPS shipping webservice. I
We're developing a new eCommerce website and are using NHibernate for the first time.
We are developing a very complex eCommerce portal using asp.net c# and the client

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.