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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:28:02+00:00 2026-05-24T20:28:02+00:00

This should be easy… why is this not easy? I am looking to have

  • 0

This should be easy… why is this not easy?

I am looking to have 2 divs side by side, where one div will auto size to the content inside and the second div will simply fill the remaining width. I need the text in the ‘remaining width’ div to be truncated if it is too large though, as I can only have these divs occupy one line.

I have been searching all day and the closest I found was this post which suggested using tables that STILL didn’t fix the issue.

Here is the jsfiddle code that reproduces my issue: http://jsfiddle.net/ssawchenko/gMxWc/

I am hoping that one of you stack-peeps can help me out!

=== CSS (Hacky) Solution? ===

Apparently adding a negative margin (that must guarantee to be big enough to cover the right size) will “work”. This seems so hacky and may not fix the issue completely though. If I drag the jsfiddle window side to side to shrink and grow the divs, some oddities occur where the shrink-to text seems to float not on the complete right.

.right_part 
{
  margin-left:-1000px; 
  background:yellow;   
  float:right;
  white-space:nowrap;
} 

=== Complete CSS Solution ===

FINALLY found the right CSS combination!

http://jsfiddle.net/ssawchenko/gKnuY/

My mistake was I was incorrectly floating my “fit to” content. By moving the div to the correct location in the DOM the content is floated correctly, and the “remaining sized” div will now correctly take up the remaining space.

I also wanted to force the divs to occupy ONE line, which is why I have set such strict CSS on the “remaining sized” div content.
overflow:hidden;
text-overflow:ellipsis;

  • 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-05-24T20:28:04+00:00Added an answer on May 24, 2026 at 8:28 pm
    #full_width_div {
        background-color:#5B8587;
        width:100%;
    }
    .left_part {
        background:red;
        white-space:nowrap;
        overflow:hidden;
        text-overflow:ellipsis;
    }
    .right_part {
       background:yellow;   
       float:right;
       white-space:nowrap;
    }
    <div id="full_width_div">
      <div class="right_part">
         Size to fit me completely
      </div>
      <div class="left_part">
         I am long and should be truncated once I meet up with the size to me text.
      </div>    
    
      <div style="clear:both;" />
    </div>

    My mistake was I was incorrectly floating my “fit to” content. By moving the div to the correct location in the DOM the content is floated correctly, and the “remaining sized” div will now correctly take up the remaining space.

    I also wanted to force the divs to occupy ONE line, which is why I have set such strict CSS on the “remaining sized” div content. overflow:hidden; text-overflow:ellipsis;

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

Sidebar

Related Questions

This should be easy but for some reason it will not work. I have
This should be an easy one. I have a table like so: <table> <tr>
Ok this should be easy but I can NOT figure it out. I have
This should be easy, but I could not find a solution. I have three
This one should be easy, I think. I have a paginated image gallery, and
This should be easy but it's not working. I have a WPF combobox bound
This seems like this should be easy but I have not been able to
This should be easy, but I'm not sure how to best go about it.
This should be easy (at least no one else seems to be having a
This should be and easy one for the LINQ gurus out there. I'm doing

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.