The exterior DIV does not conform to shrinking dimensions

I've set the display property to inline-block, but the htmlDiv div in this code snippet is not behaving as expected. It's acting as though the inner divs are next to each other even when they're not. How can I fix this?

If it's unclear, please run the animated snippet...

var demoContainer = d3.select('#demoContainer').style('width', '100px')
    function tick() {
      demoContainer.transition().duration(4000).style('width', '400px')
      .transition().duration(4000).style('width', '600px')
      .transition().duration(3000).style('width', '400px')
      .transition().duration(3000).style('width', '100px')
      .each('end', tick);
    };
    tick();
#htmlDiv {
      font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif;
  font-size: 12px;    
  outline: solid 1px black;
      background-color: rgba(0, 0, 0, 0.25);
      display: inline-block;
      position: relative;
    }

    .container {
      height: auto;
      width: 100%;
      display: inline-block;
      position: relative;
    }

    .bubbles,
    .subBubbles,
    .span {
      color: #ccc;
    }

    .select-bubbles,
    .bubbles {
      padding: 5px;
      margin: 3px;
      outline: solid 1px white;
      background-color: rgb(114, 114, 114);
      width: 150px;
      display: inline-block;
    }
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script>
<div id="demoContainer" style="outline: solid 3px red; padding: 10px">
    <div id="htmlDiv">
      I want this outer div to shrink-wrap the 4 inner divs regardless of width... <br>
      <div class="container">
        <div class="select-bubbles">
          <select class="selector">
            <option value="select">select</option>
            <option value="selectAll">selectAll</option>
          </select>
          <select id="multi-single">
            <option value="4">multi</option>
            <option value="1">single</option>
          </select>
          <div class="select-subBubbles">
            <select class="selector">
              <option value="select">select</option>
              <option value="selectAll" selected="selected">selectAll</option>
            </select>
            <span class="select-spans">
              <select class="selector">
                <option value="select">select</option>
                <option value="selectAll">selectAll</option>
              </select>
            </span>
          </div>
        </div>
      </div> <br>
      <div class="bubbles bubble1">
        bubble1
        <div class="subBubbles bubble1">
          <span>sub1</span>
          <span class="spans bubble1">
            <span style="transform: rotateX(0deg); color: rgb(0, 0, 0);" class="temp">
              sub1
            </span> subsub1
          </span>
          <span class="spans bubble2">subsub2</span>
        </div>
        <div class="subBubbles bubble2">
          <span>
            sub2
          </span>
          <span class="spans bubble1">
            <span class="temp">
              sub2
            </span>
            subsub1
          </span>
        </div>
      </div>
      <div class="bubbles bubble2">
        bubble2
        <div class="subBubbles bubble1">
          sub1
          <span class="spans bubble1">subsub1</span>
          <span class="spans bubble2">subsub2</span>
        </div>
        <div class="subBubbles bubble2">
          sub2
          <span class="spans bubble1">subsub1</span>
          <span class="spans bubble2">subsub2</span>
        </div><div class="subBubbles bubble3">
          sub3
          <span class="spans bubble1">
            subsub1
          </span>
          <span class="spans bubble2">
            subsub2
          </span>
        </div>
      </div>
      <div class="bubbles bubble2">
        bubble2
        <div class="subBubbles bubble1">
          sub1
          <span class="spans bubble1">subsub1</span>
          <span class="spans bubble2">subsub2</span>
        </div>
        <div class="subBubbles bubble2">
          sub2
          <span class="spans bubble1">subsub1</span>
          <span class="spans bubble2">subsub2</span>
        </div><div class="subBubbles bubble3">
          sub3
          <span class="spans bubble1">
            subsub1
          </span>
          <span class="spans bubble2">
            subsub2
          </span>
        </div>
      </div>
    </div>
  </div>

Answer №1

The issue lies in the code snippet below where a width of 250px was being set:

.select-bubbles, .bubbles {
     padding: 5px;
  margin: 3px;
  outline: solid 1px white;
  background-color: rgb(114, 114, 114);
  /* width: 250px; */
  /* display: inline-block; */
 }

By removing the inline-block property and the fixed width of 250px, you will allow the box to shrink less than 250px as needed.

For now, we have removed the inline-block property but feel free to add it back with additional properties for a better appearance if desired.

Answer №2

It seems like your question is a bit unclear, but I believe you are trying to achieve the following:

.container,
.select-bubbles,
.bubbles {
    display: block;
}

Make sure to use display: block instead of inline-block.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for ensuring the border matches the size of the image

I am in the process of creating a website that includes a filter option. My plan is to have the filters displayed on the left side and the items on the right side. To achieve this layout, I have implemented a scrollable div for the items. However, I notic ...

Image not being shown by ng-src

I'm struggling to get my picture to display using ng-src. <img ng-src="http://localhost:3000/images/{{image.image}}" class="img-circle" alt="User" style="width: 130px; height: auto;"> Although the data is present when I console log this: ...

The function replaceState() is unable to create a history state with a URL in a document that has a different origin

In my main.js file located in required/javascripts on my server, I have the code window.history.replaceState(null, null, 'about');. On the about page (located at the root of my server), there is a link that uses window.history.replaceState(null, ...

Challenges with pointer-events and z-index

I have been struggling to understand why I am unable to click the links in my footer. Even though my CSS may not be perfect, it does serve its purpose. There must be a more efficient way to create a footer that sticks to the bottom of the page and appears ...

Learn how to showcase real-time stock information from Yahoo Finance on an Android device. See the JSON format provided below for guidance

finance_charts_json_callback( { "meta" : { "uri" :"/instrument/1.0/PTC/chartdata;type=quote;range=1d/json/", "ticker" : "ptc", "Company-Name" : "PTC Inc.", "Exchange-Name" : "NMS", "unit" : "MIN", "timezone" : "EDT", "curr ...

Looking for a reliable tool to check your CSS classes and tidy up your code effectively?

It seems like a common issue with a straightforward solution. I have numerous CSS selectors scattered across various files, many of which may be unnecessary and a directory full of HTML files. My goal is to identify all redundant selectors in my CSS within ...

Using the jQuery/JavaScript operator is similar to the SQL LIKE query with the wildcard %

Is there a way to search for a specific part of my input using JavaScript/jQuery? I've tried two different methods, but neither yielded any results. <script type="text/javascript> $("#button").click(function () { $("#DivToToggle").toggle(); ...

Tips for designing a search bar using Angular

search : ____________ I am interested in designing a search bar functionality that automatically triggers when the user inputs 8 or more characters. The input text will be stored in a variable, the search bar will be reset, and the backend API will be che ...

Switching the color of links when they are focused, without changing it when they are clicked by either a mouse or

Is there a way to change the color of a link only when a user navigates to it using the TAB key and not when they click on it? The simple CSS solution I found was: a:focus { color: red; } However, this also changes the color when the link is activated by ...

Achieve a sliding effect between two divs using CSS only

I'm trying to create a design with 2 divs that are the same size. The first one is visible by default, while the second one is hidden initially. My goal is to achieve an effect where when you hover over the first div, the second one slides upward and ...

Arranging elements within a div using inline positioning

Currently, I am trying to arrange elements within a div. Below is the div that needs positioning: This is the desired layout: Here is the HTML and CSS code snippet: #channel-header * { display: inline-block; } #channel-title { position: absolute; ...

The Boostrap Datepicker fails to display

I'm having trouble integrating a Bootstrap Datepicker into my form. I got it working outside of the form, but when I try to include the code in my form, it doesn't seem to work. All necessary files are present and the code is identical. <!D ...

Tips for enlarging the font size of a number as the number increases

Utilizing the react-countup library to animate counting up to a specific value. When a user clicks a button, the generated value is 9.57, and through react-counter, it visually increments from 1.00 to 9.57 over time. Here's the code snippet: const { ...

Tips on Selecting a Typed Value

When clicking on 'no_results_text' and it's not available in the list, I want to show the searched value from the alert. I have included an onclick method for 'no_results_text', so that the typed value is displayed in the alert. h ...

Can multiple shadow hosts utilize a common shadow DOM?

As I navigate the world of Web Components, I find myself still grappling with a full understanding of its capabilities. One thing that stands out to me is the numerous advantages it offers. A burning question in my mind is whether it's feasible to sh ...

Only show a single li element in CSS at a time

I'm working with Angular 2 and I have a list: <ul> <li *ngFor="let show of (ann)"> {{show}} </li> </ul> I want to show one item from the list every 3 seconds in an infinite loop. Here&apos ...

Facing a dilemma: Javascript not updating HTML image source

I am facing an issue while attempting to modify the source of my HTML image element. Despite using document.getElementId('image') in my code, I am unable to make it work as intended. Surprisingly, there are no errors displayed. Interestingly, whe ...

javascript for each and every textarea

I am looking to apply my JavaScript code to all the Textarea elements on my page. $_PAGE->addJSOnLoad(" $('.textarea').each(function() { $(this).keyup(function() { var characterCount = $(this).val().length; var mes ...

PHP POST data not displaying in output

Having an issue with displaying the chosen value from a database enum in a text field on my website. The enum table has options like Bachelor of Science, Master of Science, Bachelor of Education, and Master of Education. I want to show the selected option ...

Lint error: Unrecognized attribute 'text-fill-color' in CSS (unknown properties)

My navigation bar isn't functioning, and I can't figure out why. It seems like it might be related to this snippet of code: -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; text-fill-color: trans ...