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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:56:25+00:00 2026-05-26T03:56:25+00:00

Images are all different sizes. I’m using some jquery to resize them proportionally at

  • 0

Images are all different sizes. I’m using some jquery to resize them proportionally at 170px to fit inside the 180px #co-logo div. How can I get them to line up in the center of that #co-logo? I can’t find a solution that works.

#co-logo 
{
    float: left;
    width: 180px;
    height: 180px;
    margin: 20px 0 20px 20px;
    background-color: White;
    border: 1px solid #d6d5d5;
    text-align: center;
    position: relative;
}

#co-logo img
{
    position: absolute;
    top: 50%;
    left: 50%;

}

screenshot of div and images inside

  • 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-26T03:56:26+00:00Added an answer on May 26, 2026 at 3:56 am

    As you can see in your example, the images are positioned at the center (starting from the top left corner).

    To make the center the way you desire, I suggest this solution:
    How to make an image center (vertically & horizontally) inside a bigger div

    Since you’re already using jQuery to manipulate the image’s size, add their margin-top and margin-left programmatically (half for each).

    EDIT:

    (I don’t know how you’re placing the image size, you may need to change the height() and width() by $("#co-logo img").css('height') and $("#co-logo img").css('width'))

    The javascript with jQuery to add the inline styles:
    simplified:

    $("#co-logo img").css({'margin-top': -($("#co-logo img").height() / 2) + "px", 'margin-left': -($("#co-logo img").width() / 2) + "px"});
    

    explained:

    //get the image size:
    var theHeight = $("#co-logo img").height();
    var theWidth = $("#co-logo img").width();
    
    //place them into the image styles:
    $("#co-logo img").css({'margin-top': -theHeight / 2 + "px", 'margin-left': -theWidth / 2 + "px"});
    

    EDIT 2:

    Using each to loop between every image.

    Assuming you had the same ID for each block, you need to swap it with a class, like .co-logo instead of #co-logo (because IDs are unique), call the each like this:

    $(".co-logo").each(function(){
        $("img", $(this)).css({'margin-top': -($("img", $(this)).height() / 2) + "px", 'margin-left': -($("img", $(this)).width() / 2) + "px"});
    });
    

    That will do the trick!

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

Sidebar

Related Questions

Rather than having a bunch of links that are all different sizes, I want
I have images of different sizes. I want to specify the width and the
I made patterns: images with the A letter of different sizes (from 12 to
Why on all images that show queue of commits in Pro Git book arrows
I want to round up all images that have a specific attribute and place.
How can I set all images in one line and display only the first
i am successfully inserting images into my jar file but all images go to
I would like to add a path images/ to all img tags in my
I'd like to make a gallery of all images i have under my domain
I am trying to make a combined image of all images added to a

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.