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

How to apply unique styles to multiple elements with the same class using jQuery?

How can I add different classes to multiple div elements with the same class based on their content? <div class = "flag"> Yes </div> <div class = "flag"> No </div> <div class = "flag"> Yes </div> <div class = "flag"& ...

Can you explain the distinction between "javascript:;" and "javascript:" when used in the href attribute?

Can you explain the distinction between using "javascript:;" and just "javascript:" within an anchor tag's href attribute? ...

How can the onclick attribute be modified in an HTML document?

I am looking to update the data-pro-bar-percent attribute of a progress bar from 80 to 100 when a specific link is clicked. The change in attribute needs to be as follows: data-pro-bar-percent="80" --> data-pro-bar-percent="100" This is the current HTML ...

What is the best way to incorporate scripts into the HTML of my Google Apps Script or Google Sheets?

I'm having trouble getting my Apps Script-based HTML to include any scripts. My doGet function for the HtmlService is working fine: function doGet() { return HtmlService.createHtmlOutputFromFile('myhtmlfilename'); } Regardless of whether ...

Performing automatic submission of form data without needing to redirect or refresh the page using Javascript

I am trying to find a way to automatically submit form post data without the page redirecting, but I haven't had success with any of the examples I've found that involve jquery and ajax. Currently, my code redirects the page: <!DOCTYPE html& ...

Having trouble retrieving the ID of the clicked element in AngularJS?

I have successfully implemented a function in angularjs to retrieve the id of the clicked element. Below is my code snippet html <a href="#faqinner/contactform" class="clearfix" ng-click="getCateId($event)" id="{{option.id}}"> <span class= ...

Firefox has trouble with jQuery AJAX as anchor tags in returned HTML are not clickable

The issue at hand: In Firefox, anchor tagged text in the returned HTML is not clickable (no "hand cursor" and no action), while IE 10 seems to handle it without any problems. The scenario: I am utilizing jQuery AJAX to request a PHP page that fetches HTML ...

What is the best way to duplicate several HTML input fields using jQuery?

My div is quite intricate with input fields structured like this <input type="text" name="firstname"> <input type="text" name="lastname"> <input type="text" name="email"> <input type="text" name="address"> <div id="section_toC ...

I am facing a challenge with my data, as it includes start and end values representing character indexes for styles. I need to find a way to convert this information into valid HTML tags

I have some content from another source that I must transform into proper HTML. The content contains a string such as: "Hello, how are you?" Additionally, there is a separate section detailing styling instructions. For example: 'bold:star ...

Avoid navigating through hidden tab indexes

Below is the HTML code that I am working with: <span tabindex="19"> </span> <span tabindex="20"> </span> <span tabindex="21"> </span> <span id="hidden" tabindex="22"> </span> <span tabindex="23"&g ...

A minimalist web page appearing as blank in Internet Explorer

After testing my simple web page in various browsers, I discovered that it only showed a blank white page in Internet Explorer. I combed through my CSS code and identified background = rgba(some stuff) as the unsupported line by IE. However, this particula ...

Tips for resizing user-uploaded images to fit the required dimensions outlined in the design draft using CSS or JavaScript

Hey everyone! I'm facing an issue but my English isn't great. I'll do my best to explain it thoroughly, and if anything is unclear, please feel free to let me know! So here's the problem: today there's a block for users to upload p ...

The object of type 'NoneType' does not have the 'next_element' attribute

Here we have an HTML snippet of a website with a single itemprop="brand": <dd itemprop="brand" class="attributeValue-2574930263"> <a class="link-3970392289 link__default-1151936189 attributeLink-2414863004&qu ...

Using a nested loop in Javascript to fetch JSON data

My goal is to display Categories and their corresponding subcategories in a specific order. However, my current method of using loops within loops is not producing the desired outcome: Category(Mobile) Category(Laptop) Subcategory(Iphone4) Subcategory(Iph ...

Scrolling automatically within a child element that has a maximum height limit

I am currently developing a console/terminal feature for my website. https://i.stack.imgur.com/AEFNF.jpg My objective is to allow users to input commands and receive output, which might consist of multiple lines of information. When new output is displa ...

Firefox causing images to have a white border after rendering

My image (.png) has a white border only in Firefox, despite the CSS border property being set to 0. Is there a solution to remove this unwanted border around the image? ...

Utilize ngModel in conjunction with the contenteditable attribute

I am trying to bind a model with a tag that has contenteditable=true However, it seems like ngModel only functions with input, textarea or select elements: https://docs.angularjs.org/api/ng/directive/ngModel This is why the following code does not work ...

Issue with preventDefault not functioning correctly within a Bootstrap popover when trying to submit a

I am facing an issue with a bootstrap popover element containing a form. Even though I use preventDefault() when the form is submitted, it does not actually prevent the submit action. Interestingly, when I replace the popover with a modal, the functional ...

Alter the font color of text using JavaScript in an HTML document

I am struggling to change the title color in my HTML code below, but the text color does not seem to be changing. How can I make this adjustment? /** * Generate a HTML table with the provided data */ Highcharts.Chart.prototype.generateTable ...

How can I eliminate the empty spaces around a bar chart in Kendo UI?

Struggling to eliminate the extra space surrounding the Kendo UI chart below. Could this be due to a gap or spacing issue? The goal is to create a single-line bar chart with only grey appearing on the right side. Access JSFiddle Codes Here $(doc ...