Set the height of the div to zero, regardless of its content

Currently, I am facing an issue with a tr element inside a table. Whenever it is clicked, some additional html content is appended to it. I want to achieve a smooth transition effect for the appended tr by setting its height to 0 initially and then changing it to auto on click.

Although, no matter what I try, the div does not take a height of 0. Even when I include height: 0; in the CSS, it still maintains some height.

This is how my HTML looks like:

<tr class="info_container">  
    <td colspan="7">Pick a time
        <button id="time_btn">Button</button>
        <span class="tickets_left_cont"> 7 tickets left</span>
    </td>
</tr>

Here's the relevant CSS:

.info_container {
    background: #fff;
    color: #000;
    z-index: 999;
    left: 0;
    width: 100%;
    padding: 15px;
    -webkit-transition: all 1s ease-in-out;
    -moz-transition: all 1s ease-in-out;
    -o-transition: all 1s ease-in-out;
    transition: all 1s ease-in-out;
    opacity: 0;
    text-align: left;
    font-family: BreeSerifLt;
    border-bottom: 3px solid #000;
}

#time_btn {
    outline: 0;
    padding: 10px;
    background: #9A0FC7;
    border: 0;
    color: #fff;
    display: block;
    margin-top: 10px;
    font-weight: 300;
    font-family: BreeSerifLt;
}

I'm puzzled as to why the info_container class doesn't respond to setting its height to 0 to hide the div. Any insights or suggestions are much appreciated.

Thank you!

Answer №1

When working with tables, the properties height and width essentially function as their respective minimum values: min-height and min-width.

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 adjusting the fluidity of individual columns using CSS

* { box-sizing: border-box; } /* Add a card effect for ticker(s) */ .card { background-color: rgb(24, 28, 41); padding: 5px; border-style: solid; border-width: 2px; border-color: rgb(5, 105, 256); /*rgb(196, 95, 0)*/ bord ...

What are the best methods for aligning images both horizontally and vertically in Bootstrap 4?

Currently utilizing the most recent version of Bootstrap 4, I have established a 400px div to contain images of heights ranging from 100px to 350px. Despite successfully centering the image horizontally with this code: <img src="..." class="mx-auto d-b ...

I'm having trouble with my align-items code - can anyone help me figure out what

I have been attempting to vertically align the image and text without success using the "align-items" property. My website is based on a Bootstrap template. After inspecting the section, I noticed it says "display: block." Could that be causing the issue? ...

Display or conceal elements by utilizing ng-show/ng-hide according to specific conditions

Here is the code snippet I am working with: <input class="form-field form-control" type="text" name="Website" ng-model="vm.infodata.Website" placeholder="Website Address" maxlength="50" required ng-pattern="/^(www\.)?[a-zA-Z0-9_&bs ...

Adding vibrant colors to the expansion panel within Material UI to enhance its visual appeal

How can I customize the color of the expansion panel in material ui when it is open? Is there a way to override this in material ui? Feel free to check out the code example at this link ...

The dropdown feature in Materialize does not function properly when used within a dynamically generated card

Using the materialize dropdown example within a client-side html file and initializing it with jQuery is seamless: $('.dropdown-button').dropdown({ inDuration: 300, outDuration: 225, constrain_width: false, // Does not change w ...

When I click the mouse, my drawing function starts lines from the top left corner instead of the latest point

http://codepen.io/FreelanceDev/pen/kLpJSf?editors=1010 You can find my CodePen project through the provided link. While the HTML and CSS elements are working correctly, I am facing issues with the JavaScript functionality. The desired outcome should be d ...

There is an issue with the response.write function in JavaScript, as it is missing a parenthesis after the argument list when using

response.write('Your case has been submitted successfully and an email notification will be sent shortly.<br><br>The Case# is" + caseId + "<br><h2>title</h2>'); This works perfectly fine when the concatenated value ...

Is it possible to submit a form using AJAX in WordPress without relying on WordPress functions?

As I work on constructing a website using Wordpress, I am encountering an issue with submitting a form via ajax. I'm wondering if it's possible to achieve this without relying on Wordpress functions. Currently, my code runs without errors and dis ...

Having trouble viewing the information from a post form in the express post route in node.js

I am currently working on implementing a basic login function in my project using Node.js. However, I am encountering difficulties with the Router. I am unable to display any information in my terminal from the HTML post form; it only seems to work through ...

Rearrange the sequence of table rows and modify priorities within the database

I am facing a situation where I have a table with rows that are sorted based on the INT Priority in my database. Each row contains an <input type="hidden" /> element with an ID reference to the corresponding entry in the database. In addition, there ...

Having trouble uploading files with jQuery File Upload functionality

Issue: I need to set a session variable and redirect the user to a different PHP page after uploading a .txt file using jQuery File Upload. HTML code (upload.php): <!-- The fileinput-button span is used to style the file input field as button --> ...

Reveal the administrator's details exclusively when the associated radio button is chosen

Managing administrators for a post can be done through an editing page with corresponding radio buttons. Each radio button is linked to a different administrator, and selecting one populates the form fields with that admin's details. The issue arises ...

AngularJs - A directive for handling asynchronous operations with deferred or batched processing

I've exhausted my efforts searching through Google and books for a solution, so unfortunately I don't have any code to provide at the moment. My objective is the following: 1 - Develop a directive that accepts 2 parameters in this format <r ...

How can I update a property within an object in a sequential manner, similar to taking turns in a game, using React.js?

I am currently working on a ReactJs project where I am creating a game, but I have encountered an issue. I need to alternate turns between players and generate a random number between 1 and 10 for each player, storing this random number inside their respec ...

Error: JQuery Ajax Success Handler cannot locate class method

There is a javascript Class in my code that successfully posts data, but encounters an issue when trying to access a specific function within a success handler. Although the function is found during the construction of the class and can be called from othe ...

HTML 4 Ambiguous Loading Indicator

On my basic HTML 4 webpage, I am working on an NPAPI plugin that runs a Thread in the background and returns via a JavaScript callback after a few seconds. Don't worry about the "plugin" aspect - this is a simple HTML/JavaScript question. How can I ...

You can move freely between classes A and B, as well as classes A and C, but there is no transition allowed between

A Brief Overview... Take a look at the HTML structure below: <div class="wrapper"> <div class="item above"></div> <div class="item active"></div> <div class="item below"></div> <div class="item ...

I am in need of creating a specialized Gulp task that can effectively strip out attributes from my HTML code

I am in need of a Gulp task that can iterate through all specified HTML documents and eliminate specific attributes (such as style=""). I initially attempted to accomplish this task the same way I would do it via the browser, but it seems that's not p ...

Utilizing React with file system and path dependent packages

Is there a way to utilize the quick.db package in my ReactAPP with hooks, even though React does not allow the use of FS & Path which are required for this package? I am encountering the following errors: ERROR in ./node_modules/file-uri-to-path/index.js ...