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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:09:45+00:00 2026-06-06T18:09:45+00:00

How do I center align the image to vertically and horizontally to the div.

  • 0

How do I center align the image to vertically and horizontally to the div.

I need to get this without fixing height or padding because the image sizes are not constant so it should be flexible with all the images.

Here is my trail
http://jsfiddle.net/yHdAx/2/

  • 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-06T18:09:45+00:00Added an answer on June 6, 2026 at 6:09 pm

    Hey now you can used to table-cell properties in your div as like this

    live demo http://jsfiddle.net/yHdAx/3/

    HTML

     <div style="height:800px; background-color:#CCC">
    <div class="test">
    <img src="http://static.clickbd.com/global/classified/item_img/607724_0_original.jpg" />
    </div>
    

    Css

      .test{
    background-color:red;
    height:600px; display:table-cell; vertical-align:middle;
        text-align:center;
    }
    .test img{
    max-width:50%;
    
    }
    

    more info http://www.brunildo.org/test/img_center.html

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

Sidebar

Related Questions

How can I center align (horizontally) an image inside its container div? Here's the
Need to vertically align images within a containing box like this: <span class=image-box><img src=/1_thumb.jpg></span>
I want to align a div horizontally center and vertically middle of the body
Hi I want to place a Image which is center align vertically and horizontally
I have the following CSS and HTML: .TestPadding{ width:29px; text-align:center; height:18px; padding:3px 0px 2px
I need to center an element both vertically and horizontally and the element can't
I need to center align images (variable width and height) inside block level elements
Possible Duplicate: How to make an image center (vertically & horizontally) inside a bigger
Possible Duplicate: Best way to center a <div> on a page vertically and horizontally?
I want to have my list (nav) align to the center of an image

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.