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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:20:52+00:00 2026-05-30T20:20:52+00:00

I have a few dynamically loaded images, with width and height being set inside

  • 0

I have a few dynamically loaded images, with width and height being set inside the code. Obviously it doesn’t scale them proportionally. This is the code I use to load the images dynamically:

$(function(){
    $.getJSON("inc/API.php", {command:"top3"}, function(result) {
        for(var i = 0; i<result.length; i++) {
            $("<div id='top3imgContainer'><a href='images/" + result[i].imageFileName + "' rel='shadowbox[top3]' title='" 
                + result[i].imageHeader + "'><img width='220' height='220' src='images/" + result[i].imageFileName + "' id='top3img' /></a></div>").appendTo("#divTop3");
        } Shadowbox.init({
                continuous:true,
                displayCounter:false,
                overlayColor:"#a09e92",
                overlayOpacity:0.8
            });
     });
});

The HTML:

<div id="divContent">
    <div id="divTop3">
    </div>
</div>

This is the CSS:

#divContent {
width:860px;
border: 1px solid;
border-color: #dbd9ca;
border-radius: 10px;
-moz-border-radius: 10px;
margin:5px;
margin-top:20px;
margin-bottom:20px;
padding:5px;
clear:both;
margin-bottom:20px;
}

#divTop3 {
width:850;
text-align:center;
position:relative;
}

#top3imgContainer {
width:245px;
height:270px;
background-image:url(../images_ui/frame.png);
background-repeat:no-repeat;
display:inline-block;
margin: 0 15px 0 15px;
}

img#top3img {
border-radius: 10px;
-moz-border-radius: 10px;
margin-left:13px;
margin-right:20px;
margin-top:17px;
}

And after applying the CSS this is how it looks:
http://i44.tinypic.com/168x7i9.jpg

Not exactly proportional and not really centered.
So the question is – how can I scale them proportionally? And after that – how can I center each image in its div?

Thank you!

  • 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-30T20:20:53+00:00Added an answer on May 30, 2026 at 8:20 pm

    I did this: http://jsfiddle.net/ydZJk/

    The main changes are these:

    #top3imgContainer {
        width:       100px;
        height:      120px;
        line-height: 120px;
    }
    
    img {
        vertical-align: middle;
        max-width:  100px; /* check in all browsers! */
        max-height: 120px; /* Old IEs won't like it */
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Explanation: i have few objects and im declaring them inside $(document).ready(). WHY? because in
Inside asp.net form I have few dynamically generated buttons, all of this buttons submit
Ok, so i have a few <div1> elements with static content inside of them.
I have a few divs created dynamically in Javascript.I was wondering if it is
I have a few internal Canvas xaml files which I want to load dynamically
I am trying to do a timeline. The timeline have few dynamically keyframe elements
i'm creating a web page which contains a few dynamically generated images. in my
i have a few select fields that are dynamically created by the end user
I have the following form (it is dynamically generated and I have a few
I have a few div elements that i want to dynamically apply an effect

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.