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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:03:09+00:00 2026-06-17T09:03:09+00:00

I found different suggestions on how to vertically align stuff using css. However, none

  • 0

I found different suggestions on how to vertically align stuff using css. However, none of those could handle what I wanted. Here is what I want:

In general I have some text that should fill the left half of some space and a picture that should be in the right half of the space.

If the height of the text is smaller than the picture both text and picture should vertically align at top of the space:

TextTextText   PicturePicture
TextTextText   PicturePicture
               PicturePicture

If the height of the text is greater than the height of the picture, then the the text should vertically align on top and the picture at the middle relative to the text.

TextTextText
TextTextText   PicturePicture
TextTextText   PicturePicture
TextTextText   PicturePicture
TextTextText

Here is one straight forward way I tried (text-version without picture):

<div style="width: 100%">
  <div style="width: 50%; display: inline-block; vertical-align: top;">
    TextTextText <br>
    TextTextText <br>
    TextTextText
  </div><div style="width: 50%; display: inline-block; vertical-align: middle;">
    PicturePicture <br>
    PicturePicture
  </div>
</div>

However, the effect I intended was not achieved. The right inner div (Picture) is just aligned on top rather than in the middle relative to the text. There is no difference between setting vertical-align: middle and vertical-align: top. However, interestingly setting vertical-align: bottom makes a difference.

The outer div is contained in some other element of a certain width. However, I cannot specify this width by any fixed measure, e.g. px. Same for the two inner divs with equal width.

Making the inner divs table cells achieved the right vertical effect. However, I cannot use display: table-cell, since I need to make sure that the left inner div maintains its width even though the right inner div could have content that overflows to the right, like PicturePicturePicturePicturePicture.... This would lead to shrinking the width of the left cell, which I don’t want.

Furthermore, I do not know the height of the content, so none of the tricks for vertical alignment that use a fixed height works.

It seemed not an too uncommon task, but I was unable to find any solution. Is it possible to do this?

  • 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-17T09:03:10+00:00Added an answer on June 17, 2026 at 9:03 am

    It’s not clear to me what behaviour you want when the picture is too wide for the right inner div, other than it should not affect the width of the left inner div, but does this meet your requirements?

    HTML.

    <div class="container">
      <div class="caption cell">
        Text Text Text <br/>
        Text Text Text <br/>
        Text Text Text <br/>
        Text Text Text <br/>
        Text Text Text <br/>
        Text Text Text
      </div>
    
      <div class="picture cell">
        <div>
          <img src="http://placehold.it/500x50" />
        </div>
      </div>
    </div>
    

    CSS

    .container {display:table; table-layout: fixed; width:100%; }
    .cell { display: table-cell; width:50%; }
    .caption { vertical-align: top; }
    .picture { vertical-align: middle; }
    .picture div { overflow-x:hidden; }
    

    JSFiddle at http://jsfiddle.net/92wcy/1/

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

Sidebar

Related Questions

I have searched and found a lot of different things but none that actually
Following on from a question I posted yesterday. Found here: Append different div id
I found different Stackoverflow-Questons, but I don't see what I'm doing wrong in my
I have found two different things in two well known books in c, first
While googling I found two different sets of headers that need to be set
I have tried a variety of different solutions found on stack and other places
I found there're two different opinions about how greedy regex is executed: one is,
I found out that I can use a different theme in an C# WPF
I've found a feature on two different websites that I'd like to include on
I've found a couple of different twitter gem (for ruby-on-rails) out there: http://twitter4r.rubyforge.org/ http://twitter.rubyforge.org/

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.