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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:16:45+00:00 2026-06-08T00:16:45+00:00

I’m looking for a way to have a HTML container fit the width of

  • 0

I’m looking for a way to have a HTML container fit the width of one of its children.

OK I know, this is how it already works by design.

But! I also need another children to collapse with a “text-overflow: ellipsis”. Problem is: to apply such a property, you need this children to be in “display: block” mode, which makes it enlarge the container width.

Is there any secret time to achieve what I’m looking for.

Here is a JsFiddle in case you don’t get it or want to give it a try.

Edit : by the way, and this is important, I’m targetting specifically Internet Explorer 10.

  • 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-08T00:16:47+00:00Added an answer on June 8, 2026 at 12:16 am

    As watson said, there is no “shrink-to-fit” css rule. So, you have two choices:

    1. Set the size of the .overflow elements manually and statically. So, instead of width:100%, you put width:330px.

    2. Use javascript to resize the .overflow elements dynamically. (I’m assuming you have more than one.) You said you wanted to shrink to the biggest internal div. Let’s say you have several divs you might want to shrink to, but you want to shrink to the largest of them. First, you set them all to a class like this:

      .good-width{
          border: solid 2px salmon;
          width:auto; /* necessary for some browsers' offsetWidth */
          display:inline-block; /* gives it the width of the contents */
      }
      

    And you put javascript something like this at the top of the page:

    var goods = document.getElementsByClassName('good-width');
    //collect the widest one's width
    var maxwidth = 0;
    for(var x = 0; x < goods.length; x++) {
        if(goods[x].offsetWidth > maxwidth) {
            maxwidth = goods[x].offsetWidth;
        }
    }
    //set the width of the overflow divs to match
    var overflows = document.getElementsByClassName('overflow');
    for(var y = 0; y < overflows.length; y++) {
        overflows[y].style.width = maxwidth + 'px';
    }
    

    If I misunderstood, and you’re trying to match specific overflows to specific good-widths, you should assign each element an id and do things that way:

    document.getElementById('overflowID').style.width = document.getElementById('good-widthID').offsetWidth + 'px';
    

    If it were my website, I would actually combine both #1 and #2, in order to have it look at least decent for those who don’t have javascript. That is, you set a static width to the overflow things that isn’t too far off, then allow the javascript to overwrite it if it can.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I have thousands of HTML files to process using Groovy/Java and I need to
I have some data like this: 1 2 3 4 5 9 2 6

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.