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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:14:56+00:00 2026-06-11T06:14:56+00:00

I have 3 images vertically aligned in fixed height div. How can I make

  • 0

I have 3 images vertically aligned in fixed height div. How can I make sure that the top and bottom padding between them remains even when an image is added or deleted.

Say the Div height is 100px and the image height is 20px. So 3 images with 20px would sum up to 60px. The remaining 40px should evenly get distributed as padding between the images.

Similarly when another image is added, the remaining 20px should be total padding between all images.

The property : vertical-align: middle is not working here.

  • 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-11T06:14:58+00:00Added an answer on June 11, 2026 at 6:14 am

    You want to:

    1. set the div to display:table with a fixed height,
    2. wrap each <img> in element with display:table-row and display:table-cell
    3. set the images to display:block
    4. set the table-cell elements to vertical-align:middle
    5. set the height of the first and last rows to be exactly as tall as the images themselves

    This will cause the space to be evenly distributed vertically.

    Demo: http://jsfiddle.net/X2URZ/2/

    Code:

    <ul id="img-list">
      <li><span><img src="http://phrogz.net/tmp/gkhead.jpg"></span></li>
      <li><span><img src="http://phrogz.net/tmp/gkhead.jpg"></span></li>
      <li><span><img src="http://phrogz.net/tmp/gkhead.jpg"></span></li>
    </ul>​
    
    #img-list { display:table; height:100px }
    #img-list img { height:20px; display:block }
    #img-list li { display:table-row }
    #img-list li span { display:table-cell; vertical-align:middle; background:red }
    #img-list li:first-child,
    #img-list li:last-child { height:20px }​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have five 32x32 pixel images in a div container I can easily
I'm trying to layout images vertically aligned bottom (see picture below) in a responsive
i have problem with image vertical-align in div .img_thumb { float: left; height: 120px;
I have images on my website that the user needs to allow the Facebook
I have images that need to scale to the screen's size. The images will
I'm trying to make an horizontal menu, vertically and horizontally aligned. I'm actually using
I have an ImageView that you can use to do a one-finger pan, or
I have a UITabBar without titles and I need to center tabs images vertically.
I have a div ( #main ) that has been centred to the middle
The html below should essentially be a list of images aligned vertically on the

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.