Evolution of table size

I have a table that needs to expand smoothly when a certain row is clicked. I want to add a transition effect for a more polished look.

Here's my test table:

  <div ng-app="app">
    <table>
      <thead ng-controller="TestController">
        <tr>
          <th>
            head
          </th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>
            first
          </td>
        </tr>
        <tr>
          <td>
            second
          </td>
        </tr>
        <tr ng-show="display">
          <td>
            third
          </td>
        </tr>
        <tr ng-show="display">
          <td>
            fourth
          </td>
        </tr>
        <tr ng-show="display">
          <td>
            fifth
          </td>
        </tr>
        <tr ng-click="display = !display" class="last-color">
          <td>
            click me
          </td>
        </tr>
      </tbody>
    </table>
  </div>

CSS:

table {
  border: solid 1px;
}

td {
  border: solid 2px;
}

.last-color td {
  background-color: green;
}

tbody {
    transition: height 2s;
}

My example on JSFiddle

Answer â„–1

One benefit of CSS3 transitions is the ability to smoothly change property values over a specified duration. To see these transitions in action, both starting and ending values must be explicitly defined in your CSS.

In addition, it's important to note that height transitions cannot be applied directly to table elements (<table>, <tbody>, <tr>, <td>, etc.). However, by wrapping the content within <div> elements, you can then apply CSS transitions to these wrapper elements.

For a demonstration, check out this example: https://jsfiddle.net/r4w1u5or/3/

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 can I code a div to automatically scroll to the top of the page?

I'm attempting to implement something similar in WordPress - I want a div containing an advertisement to initially start 300px down the page, then scroll up with the page until it reaches the top, and finally stay there if the user continues to scroll ...

The ng-show and ng-hide directives are not working as expected, and there are no error

I'm currently working on a Todo App using AngularJS 1.x (version 1.6), but I'm having issues with ng-show and ng-hide functionality. The aim is to have a text box appear in the todo section when the edit button is clicked to modify existing todos ...

Information retrieved from Angular $http request using asp.net api is not populating the DOM

After confirming that the data is successfully reaching my Angular function, I find myself struggling to display it in the DOM. I am keeping things simple before diving into full CRUD operations. I know I must be overlooking something basic, especially si ...

Disabling the submit button after submitting the form results in the page failing to load

I am encountering an issue with my HTML form that submits to another page via POST. After the form validates, I attempt to disable or hide the submit button to prevent double submission and inform the user that the next page may take some time to load. He ...

Is it possible to utilize the output of a function to determine the styling of a div element in Vue?

Hi, I'm trying to use the v-bind:style in my div to apply the textposit function with the textpos prop as a parameter. The function should adjust the style of the div based on the value of the parameter. <div class="container" :style=&qu ...

What could be causing the Or operator to malfunction within the ng-pattern attribute in AngularJS?

Currently, I am implementing the ng-pattern="/^(([A-Za-z]{0,5}) | ([0-9]{0,10}))$/". However, it seems like the input control is not accepting values such as "asd" or "09", despite my expectation that both should be valid inputs. Do you think the pipe sy ...

Is it possible to send both props and a function within a single onClick event in React?

After spending hours searching for the right solution, I have yet to find it. Let me explain my situation clearly. I have an Image Carousel feature on my website that should open when a user clicks on an image. I have 5 images on the website, and when a us ...

Unlocking the potential of Object[value] in JavaScript/jQuery: A guide to extracting its value

I have a table named 'mytable' with the following structure: <tr> <td><input type="checkbox" name="check[]" value="11"></td> <td>11</td> <td>2014-11-06 18:49:26</td> < ...

Is there a specific requirement for importing a React component into a particular file?

I am facing an issue with my component and two JavaScript files: index.js and App.js. When I import the component into index.js, it displays correctly on the screen. However, when I import it into App.js, nothing appears on the screen. Here is the code fr ...

What steps should be taken to activate eslint caching?

I'm attempting to activate eslint caching by following the instructions in this section of the user guide The command I am using is npm run lint -- --cache=true, and the lint script simply executes a script that spawns esw (which itself runs eslint â ...

Having difficulty resolving all parameters for the component: (?, [object Object]) in the Jasmine component Unit Test

While defining a UT for a component with an extended class using i8nService and ChangeDetectionRef, I encountered an error preventing me from instantiating it: Failed: Can't resolve all parameters for BrandingMultiselectComponent: (?, [object Object] ...

Activate a tooltip in Vuetify

I'm utilizing vuetify and have implemented a tooltip feature on a button. However, I do not want the tooltip to be displayed on hover or click; instead, I would like it to appear when a specific event is triggered. translate.vue <v-tooltip v-model ...

What is the best way to add data from an array to a DOM element in the same order it was retrieved from Firebase?

Utilizing Google Firebase Firestore for data storage and the Open Movie Database (OMD) in combination with Axios to retrieve movie information. I am currently developing a website that allows users to add movies to collections. On the collections page, al ...

Execute the validation directive using the digest cycle

This particular directive is designed to determine whether a given value exists within the associated datalist or not. It functions flawlessly when I input text into the field, but it fails to work properly if the datalist undergoes changes as a result o ...

Can angular $q.all() achieve the same level of success as jQuery $.get()?

Upon reviewing the jQuery documentation, I discovered the following: $.get( "example.php", function() { alert( "success" ); }) .done(function() { alert( "second success" ); <--- }) .fail(function() { alert( "error" ); }) .always(fun ...

Transitioning to the Bootstrap library from the jQuery library with the use of several image modals

After coming across this specific question about implementing multiple image modals on a webpage, I noticed that it primarily focused on javascript and jQuery. However, my project involves utilizing the latest version of Bootstrap, so I'm curious if t ...

Unlock the power of polymer iron-ajax by seamlessly linking input element data to the iron-ajax's body attribute

Having some trouble binding data from an input element to the "body" attribute of iron-ajax. In the past, using core-ajax in Polymer 0.5, I could easily bind values like so: <core-ajax id="ajax" method="POST" contentTy ...

Utilize the existing Mongoose schema within the client-side code for better

I'm in the process of creating a MEANJS application and I've already set up a Mongoose schema. Now, I want to utilize this schema on the client side to validate forms using Mongoose in the browser. The initial setup of the application was done w ...

Django form submission triggers Jquery modal to confirm object deletion

I'm currently working with Django and Crispy forms while also utilizing the Shopify Embedded Apps SDK. My goal is to implement a modal window that prompts the user to confirm the deletion of an object. My progress code is attached below. Although I h ...

Is there a way to still access the data from a radio button even if it hasn't been selected?

I'm currently working on a questionnaire feature and facing an issue where I need to capture all answers, even if the radio button is not checked. Here's a snippet of the HTML code: $('input:radio').each(function () { if ($(this). ...