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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:26:50+00:00 2026-06-13T00:26:50+00:00

I’m using this code to center images in a thumbnail field within a result

  • 0

I’m using this code to center images in a thumbnail field within a result div when displaying data:

<div class='result'>
    <div class='date_field'>15 Okt</div>
    <div class='thumbnail_field th_div'><img src='p.png' class='thumb'></div>
    <div class='content_field'><a href="p.html">p</a></div>
    <div class='price_field'>5</div>
</div>

.result{position: relative;background-color: white;height: 100px;overflow: hidden;margin: 0px 10px;}
.thumbnail_field{position: absolute;top: 8;left: 15%;width: 100px;height: 75px;background-color: #FFF;}
.th_div img{position: absolute;}

$(document).ready(function(){
var h = 75;
var w = 100;
$('.thumb').each(function(){
    $(this).load(function() {
        var width=$(this).width();
        var height=$(this).height();
        var ratio=width/height;
        var pwidth=$(this).parent().width();
        var pheight=$(this).parent().height();
        var newheight;
        var topmargin;
        var newwidth;
        var leftmargin;

        if(width/height>=4/3){
            $(this).css("width",w);
            newheight=w/ratio;
            topmargin=(h-newheight)/2;
            $(this).css("top",topmargin+"px")
        }else{
            $(this).css("height",h);
            newwidth=h*ratio;
            leftmargin=(w-newwidth)/2;
            $(this).css("left",leftmargin+"px")
        }

    });
});
});

It is working in Chrome and Firefox but works randomly in IE 8. Any tips about what can be the 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-06-13T00:26:51+00:00Added an answer on June 13, 2026 at 12:26 am

    It could be a caching issue with the $.load function.

    The callback for the load function fires if the image is not already present in your browser cache. If the image is present in the cache, the image load function callback is not executed – which explains the erratic behavior of the code on IE8.

    More info around this here: jQuery .load() problem in all IE versions

    This caveat also listed in the jQuery .load() description page: http://api.jquery.com/load-event/

    Solution:

    $(".thumb").one("load",function(){
    // Add your positioning code here
    })
    .each(function(){
    if(this.complete) $(this).trigger("load");
    });
    

    Cheers!

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am reading a book about Javascript and jQuery and using one of the
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,

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.