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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:08:51+00:00 2026-06-14T15:08:51+00:00

Possible Duplicate: Image center align vertically and horizontally I’m uploading images to a php

  • 0

Possible Duplicate:
Image center align vertically and horizontally

I’m uploading images to a php file so I can resize them to a certain width or height, which ever is smaller. The image resizer I’m using is a class from phpclasses.org and it seems to be working pretty good. The problem is, not all images are the same size. Some are wide and narrow while some are almost square. So this is causing all the images to position on the top of my div and not the middle. My thought is to have CSS perfectly center the images so the different sizes look decent when viewed, but I can get them to center horizontally but not vertically. Here’s a screenshot of what I”m trying to center:

enter image description here

As you can see the guns are aligned on top of the div? I can’t use a hard coded figure to push it center since other images will have different heights. I need some way of determining the size of the image and figuring it from there.

Here’s the code for the div’s that the images are in:

#product {
    float:left;
    margin:5px;
    width:200px;
    height:200px;
    border:1px solid #999;
}
#product-image {
    margin:2px auto;
    width:194px;
    height:145px;
    border:1px solid #999;
    text-align:center;
}

Thanks for having a look.

  • 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-14T15:08:52+00:00Added an answer on June 14, 2026 at 3:08 pm
    #product
    {
        width: 200px;
        height: 200px;
        line-height: 200px;
        text-align: center;
    }
    #product img
    {
        vertical-align: middle;
        max-height: 200px;
        max-width: 200px;
    }
    

    Max-Height / Max-Width is used to handle images that may be too large.

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

Sidebar

Related Questions

Possible Duplicate: How to center div horizontally and vertically I need to put image
Possible Duplicate: .htaccess rewrite image file to php script How can I execute a
Possible Duplicate: PHP image resize on the fly vs storing resized images I was
Possible Duplicate: PHP code can insert image to excel file and open it correctly
Possible Duplicate: How to make an image center (vertically & horizontally) inside a bigger
Possible Duplicate: How to make an image center (vertically & horizontally) inside a bigger
Possible Duplicate: How to make an image center (vertically & horizontally) inside a bigger
Possible Duplicate: How do I vertically align text next to an image with CSS?
Possible Duplicate: Image uploading via PHP returning empty array I am unable to successfully
Possible Duplicate: save image from php url using php How can i use 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.