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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:29:29+00:00 2026-06-09T02:29:29+00:00

I am trying to avoid using layout table in this jsFiddle , and I

  • 0

I am trying to avoid using layout table in this jsFiddle, and I need to come up with more semantic and generic markup plus CSS.

There is an image in the left column and description in the right column.

There are few challenges, however: we don’t know any pixel dimensions, and description may be quite long, which is why we cannot simply float two divs side by side.

Image also needs to be vertically aligned, but we don’t know container height or image size.

Display: table is not an option. Javascript is not an option

<table>
 <tr>
    <td class="image">
        <img src="http://blog.stackoverflow.com/wp-content/uploads/stackoverflow-logo-300.png">
    </td>

    <td class="description">
        <p>Left section only needs to be as wide as image is, and we don't know pixel size of the image. It has to be vertically centered.</p>

        <p>Right section should take all available space left</p>

        <p>We do not know how much text will be in the right section.</p>            
        <p>We can not use display: table since solutions needs to work in IE7 as well</p>                        
    </td>
  </tr>
<table>

Please throw any ideas:)

  • 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-09T02:29:30+00:00Added an answer on June 9, 2026 at 2:29 am

    Here’s your solution:

    http://jsfiddle.net/ZXfFG/3/

    Explanation:

    So you have 2 problems: 1) Adjusting the width and height of the 2 columns. 2) Positioning the image vertically.

    Solutions:

    1) the left column’s width will adjust automatically because it will adjust to the its child’s (image) width. setting its float property to left will stick the text right next to it. This is fine when the text is shorter than the image, but what if it’s longer like you mentioned? then you will get something like this:

    enter image description here

    so we need to make the right column behave like a rectangle. Normally you would set the height of the left column to 100% and that would take care of the problem, but that won’t work since its parent doesn’t have a fixed height. Anyway, setting the overflow property of the right column will take care of this problem.

    .right {
        overflow:hidden;
    }
    

    2) Setting the image centered vertically is impossible without JavaScript or using a table layout. but here’s what you can do: hide the image by setting its visibility to hidden, this way the left column will still take its width. and then set the background image of the parent container to the image and position it left center.

    .container {
        background:url("http://www.sourcegate.com/images/stackoverflow-logo.png") left center no-repeat;  
    }
    

    That concludes the non-js, non-table solution, but If somewhere in your heart you want find that you want to give javascript a try, there are a lot of ways of doing it, but this is what I would do: (1 line of code)

    ​$(".container").css('padding-left', $('img').width() + "px");​​​​​​​​​​​​​​​​

    http://jsfiddle.net/GtEdc/

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

Sidebar

Related Questions

I'm trying to avoid using queries in while loops. Therefore I've come to the
I am trying to avoid using intents and activities within tabhost and tabwidget This
I've been trying to avoid using a cursor in this particular case just because
This is a follow-up to this question . I'm trying to avoid using an
I'm trying to avoid using Interface Builder as much as possible. At the moment
I am trying to avoid using Net::SSH::Perl library since there is some problems in
I'm probably over-thinking this/wasting time trying to avoid a bit of conditional code -
I'm trying to make a dotted line. I'm using this right now for a
I am trying to avoid using a scalar valued functions in my project, so
I'm trying to keep track of the state in this app using Backbone.js: I

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.