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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:50:45+00:00 2026-05-21T05:50:45+00:00

With jQuery how can I see if a div is less than 75px, and

  • 0

With jQuery how can I see if a div is less than 75px, and if it is add 1/2 (half) the difference as left padding?

So if an image is 75px or bigger, then nothing happens, but if it’s 71px then 2px of left-padding is applied.

Note, the size is defined by CSS, the actual images are bigger.

Thanks

The following didn’t work for me:

$(window).load(function() {
    $(function(){ 
        var img= $('#views_slideshow_singleframe_pager_product_slideshow-node_content_1 .pager-item img');
        if(img.width() <75)
        {
            img.css("padding-left", (img.width() -75)/2);
    });
});

UPDATE – I need to target several images on a page with this.

UPDATE – I’m adding the code suggestions locally so you cant see it live, but a non-js version of the site is here: link – click on one of the thumbnails under the ‘SIZE’ drop down box to see a thumbnail that’s too small. This version is a little out of date so I’ll come back with a newer one as soon as its uploaded. Thanks

UPDATE – the thumbnail images are themselves generated by javascript, so the code needs to be run after they’re created. I’ve used window load for this reason.

  • 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-21T05:50:45+00:00Added an answer on May 21, 2026 at 5:50 am

    Try this jQuery, I’m not sure how bug-proof it is, though:

    $('img').live('click', function() {
      $.each($('img'), function() {
        var image = $(this);
    
        if (image.width() < 75) {
          image.css('padding-left', ((75 - image.width()) / 2)); 
        }
      });
    });
    

    EDIT : This code will fire each time any image is clicked. You can make this more specific by using a selector to find clicked images within a certain container, such as a “div”.

    I hope it helps, though,
    spryno724

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

Sidebar

Related Questions

As you can see on http://jsbin.com/erivi/ I'm using Jquery to change some image (and
i'm trying to replicate what you can see in the image here in jquery
I can see there are many ways to use jQuery safely in the javascript
How can I remove the animation from this jQuery modal window? You can see
I'm working on a jquery carousel. You can see the example here: http://jsfiddle.net/6fwbS/2/ Click
Im trying to use this page slider jquery plugin, you can see the demo
I am using the jQuery DataTable plug-in and can not see to find a
I'm having some serious issues with the jQuery UI icons and I can't see
Please see the jQuery below: I am really wondering how can I use CSS
JQuery - Can we capture both the p and div tags at a time

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.