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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:46:29+00:00 2026-06-10T00:46:29+00:00

I have a container which is 100px by 100px. I have put an image

  • 0

I have a container which is 100px by 100px. I have put an image in it which I don’t know the dimensions, except the fact that I have set the width to 100px. I would like to find a way in CSS to vertically align this image middle in it’s container. I have stuck overflow:hidden on the container to prevent it from showing anything outside the square.

I have found something on here on how to do the opposite (width, not height).

  • 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-10T00:46:31+00:00Added an answer on June 10, 2026 at 12:46 am

    Wrap the image inside two divs that will mimic an html table. The outer div will have display: table property, and the inner will have display: table-cell property. You can set the vertical-align property of the inner div to be top, middle, or bottom.

    HTML:

    <div class="table">
        <div class="table-cell middle">
            <img src="https://www.google.ca/images/srpr/logo3w.png" alt="" />
        </div>
    </div>​
    

    CSS:

    .table {
        display: table;
        width: 100px;
        height: 100px;
        border: 1px solid blue;
    }
    .table-cell {
        display: table-cell;
    }
    .middle {
        vertical-align: middle;
    }
    img {
        width: 100%;
        outline: 1px solid red;
    }
    

    Here’s the fiddle.

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

Sidebar

Related Questions

I have a container class which I would like to use to print all
I have a container layer with a width of 850px. Inside of that i
I have an image gallery that, at the moment, displays only images. I would
I have a parent div (container) that has a child div (inner) which also
I have one container div which contain 2 dynamic height (height haven't been set)
I have a container with a specified width of 980px that contains inline-block elements.
I have a container DIV which contains several block-DIVS. Every block-DIV contains SPAN items
I have a container class which uses boost::optional to hold the value. Here is
i have a container div which is position:relative and the squares are position:absolute because
suppose I have a simple container which have three element: <div> <span>hello world</span> <input

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.