Eliminating the excessive space underneath the collapsible section when it is expanded

I am facing an issue with a hidden html table inside a collapsible element. Whenever the collapsible is expanded, there seems to be a substantial gap below the table. I'm unable to identify the cause of this problem.

Below, you will find images and a demo that illustrate the issue. Your assistance is greatly appreciated.

Collapsible Expanded

https://i.sstatic.net/LZBvS.png

Collapsible Closed

https://i.sstatic.net/cSgIH.png

DEMO:

var coll = document.getElementsByClassName("collapsible");
var i;

for (i = 0; i < coll.length; i++) {
  coll[i].addEventListener("click", function() {
    this.classList.toggle("active");
    var content = this.nextElementSibling;
    if (content.style.maxHeight){
      content.style.maxHeight = null;
    } else {
      content.style.maxHeight = content.scrollHeight + "px";
    }
  });
}
.collapsible{
  background-color: #1E1E1E;
  border: none;
  cursor: pointer;
}
.collapsible:before {
  content: '▶';
  font-size: 10px;
  float: left;
  color: white;
  padding-top: 13px;
}
.collapsible.active:before {
  content: "▼";
}
.content {
  padding: 0 0px;
  overflow: hidden;
  color: white;
  font-size: 10px;
  font-family: 'Oswald', sans-serif;
  max-height: 0;
  transition: max-height 0.2s ease-out;
}
<button type="button" class="collapsible"><h3 id="Accounts">&nbsp;Fiat Accounts</h3></button>
 <div class="content" id="acc_list">
  <table class="acc_table" id="acc_table">
    <tr id=acc_row1>
      <td id="acc_name1" class="accname">Cash</td>
      <td id="acc_balance1" class="accbal">$5322.54<button class="edit_account" id="editaccounts">✎</button></td>
    </tr>
    <tr id=acc_row2>
      <td id="acc_name2" class="accname">Credit Card</td>
      <td id=acc_balance2 class="accbal">$1362.21<button class="edit_account" id="editaccounts">✎</button></td>
    </tr>
    <tr id=acc_row3>
      <td id="acc_name3" class="accname">Checking Account</td>
      <td id=acc_balance3 class="accbal">$4322.50<button class="edit_account" id="editaccounts">✎</button></td>
    </tr>
    <tr id=acc_row4>
      <td id="acc_name4" class="accname">Savings Account</td>
      <td id=acc_balance4 class="accbal">$12322.50<button class="edit_account" id="editaccounts">✎</button></td>
    </tr>   
  </table>
</div>

Answer №1

After examining developer mode, I identified that the culprit was the .tbody{height} code snippet. Appreciate the helpful advice!

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 keeping buttons anchored at the bottom of the page during scrolling

As a newcomer to Ionic, HTML, and CSS, I am currently exploring how to keep a button fixed while scrolling through the page. Despite specifying a fixed position in the CSS, the button does not remain fixed as intended. The button seems to be having troubl ...

Remove an item from a multidimensional array that contains a specific key-value pair

I need to remove the low-level object (for example, in the code below, under personal data there are two objects, I want to delete the one where action is "OLD") under each section where the "action" is "OLD" I'm utilizing lodash in my current projec ...

How can you create a personalized sorting order using odata?

Within my AngularApp, I retrieve data from a WebAPI using OData queries. All the retrieved results contain both a date and an integer status code. The status codes range from 1 to 4. I am aiming to organize my results in such a way that all items with a ...

Include the name of the uploaded attachment in the textarea before hitting the submit button

Is there a way to automatically insert the filename into a textarea before the user submits the form? Can this be achieved using PHP or JavaScript? Thank you. <form id="Apply" name="Apply" method="post" enctype="multipart/form-data" action="applyLea ...

Modify flex direction to column in response to changes in height of another div or when its content wraps

I am currently utilizing React MUI V5 and I am looking to modify the flex direction of a div from row to column when a preceding div changes in height or wraps. Below is a basic example of what I have implemented using plain HTML/CSS, but I am uncertain i ...

Struggling to Enforce Restricted Imports in TypeScript Project Even After Setting baseUrl and resolve Configuration

I am facing challenges enforcing restricted imports in my TypeScript project using ESLint. The configuration seems to be causing issues for me. I have configured the baseUrl in my tsconfig.json file as "src" and attempted to use modules in my ESLint setup ...

Acquire HTML table information in array format using JavaScript

I am searching for a script that can extract the 2D array of rows and columns from an HTML table within a div element. The desired array output should be: [ ["Company", "Contact", "Country"], ["Alfreds Futterkiste", "Maria Anders", "Germany"], ...

How can I pass a dynamic scope variable to a JavaScript function in AngularJS that is being updated within an ng-repeat loop?

In my HTML, I have an ng-repeat loop where a variable is displayed in table rows. I want the user to be able to click on a value and pass it to a JavaScript function for further action. The code snippet below showcases my earlier version which successful ...

Challenges with the Placement of Buttons

I am facing an issue with the code below: document.addEventListener("DOMContentLoaded", function(event) { // Select all the read more buttons and hidden contents const readMoreButtons = document.querySelectorAll(".read-more"); const hiddenConten ...

Resize a circle upon hovering while keeping the same thickness of the border

I'm working on creating a circle with just a border (no background) that scales on hover. Here's the code I have so far: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <link type="text/css" rel="stylesh ...

Error: Attempting to access the property 'push' of an undefined variable has resulted in an unhandled TypeError

if (Math.random() <= .1) { let orgAdmin = User.find({email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1234454665324721380c0d">[email protected]</a>'}); or ...

Modify the colors of the chartist fill and stroke using JavaScript

Struggling to dynamically set colors in a chartist graph using JavaScript. How can custom colors be applied through JS? The attempted method below is not successfully changing the color for the showArea in the chartist graph. <!doctype html> <htm ...

Angular provides a variety of functionality to control the behavior of elements in your application, including the

I have a page with Play, Pause, Resume, and Stop icons. When I click on the Play icon, the Pause and Stop icons are displayed. Similarly, I would like to show the Resume and Stop icons when I click on the Pause icon. I need help with this code. Thank you. ...

Enabling sidebar functionality for every component in React JS using React Router v6

I am currently using react router dom v6 and encountering an issue where the sidebar disappears whenever I click on any component in the app. I need to find a way to keep the sidebar visible across all components. Sidebar Available https://i.sstatic.net/ ...

Exploring the depths of recursion with jQuery: Unraveling the

Having some issues with a recursive function in jQuery that's throwing an exception: 'Uncaught RangeError: Maximum call stack size exceeded' I can't figure out why this recursive function might be running infinitely. Any help would be ...

Creating a scoreboard layout with HTML and CSS

I am attempting to create a scoreboard in the following format: 0 - 0 Home - Away The issue I am facing is that if the length of the Home team's name is longer, it pushes the dash (-) further. I want the dash to be a ...

Tips on incorporating a button to enable text formatting to 'bold' within a Text Area on an HTML webpage:

In the process of creating an online text editor, I am looking to incorporate a button above the text area that can be used to make selected text and/or upcoming text bold. To provide more clarity, I envision adding a bold button similar to the one found a ...

What is the reason behind encountering these errors while trying to run my Gatsby development server?

I'm currently working on the part three tutorial provided by Gatsby on their official website and I've encountered a problem. Upon executing the command gatsby new tutorial-part-three https://github.com/gatsbyjs/gatsby-starter-hello-world I rec ...

A guide to utilizing CSS to showcase the content of all four div elements in HTML body simultaneously

Is there a way to use CSS to display the content of all 4 divs in the same place on the HTML body, based on the URL clicked? Only one div should be displayed at a time in the center of the page. For example, if URL #1 is clicked, it should show the conten ...

I need to adjust the alignment of the text within my list item that includes a time element

I am struggling with aligning my elements vertically downward as the text following the "-" appears disorganized. I attempted to enclose the time tags within div elements and align them so that they evenly occupy space, but this approach did not work. Ins ...