Animate the jQuery display property to show a table without changing any specified spatial dimensions

When utilizing jQuery's $.animate() on an element styled with display:table, any spatial dimensions that are not explicitly specified to change will animate.

Check out the fiddle here

In the scenario presented, the width is defined for animation, but the height is not. This leads to erratic behavior in the height of the table display. How can the visual changes in a display:table's height be prevented?

HTML

<div style="display:table; height:40px;">
    <div style="display:table-row">
        <div class="cell">
            Short text
        </div>
        <div class="cell cellToAnimate">
            Really long text
        </div>
        <div class="cell cellToAnimate">
            Really, really, really long text
        </div>
    </div>
</div>
<div>
<button type="button" id="cellChanger">Change cells</button>

CSS

.cell{
    display:table-cell;
}

JavaScript

$(document).ready(function () {

$('.cellToAnimate').hide();

$("#cellChanger").click(function(){
    $('.cellToAnimate').stop(true,false).animate({
        width: 'toggle',
        opacity: 'toggle'
    });
});

});

Answer №1

design a wrapper using

display: block;
height: 40px;
overflow: hidden;

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

Shifting the placement of a button with the help of bootstrap

Having a bit of trouble trying to adjust the position of a button inside an input field using bootstrap. The button appears centered within the form field, but I need it to be slightly shifted to the right for design consistency. https://i.stack.imgur.com ...

Using jQuery to remove an iframe upon a click event

My goal is to remove an iframe whenever anything on the page is clicked. I tried using this code: $('*').on('click',function(){ $('iframe').remove(); }); However, I encountered a problem where the i ...

Partially accessible Angular service within a callback function

I'm currently facing an issue in my Angular simple app related to a factory that is not fully available within a callback function. You can check out a simplified version of the application on this Plunkr link. Here's a snippet of the code: Th ...

Moving data from one table to another and making changes or removing it

After successfully adding data from one table to another using .click, I encountered an issue. Whenever I utilize the search field in the top table, it clears the appended rows in the bottom table. I am looking for a solution to have these tables generate ...

What could be causing this `even` function to malfunction when utilizing getElementById?

Need assistance with utilizing document.getElementById? Let's take a look at this code snippet: function even() for (i = 0; i < 10; i++) { if (i % 2 == 0) { alert(i); } } document.getElementById("even").innerHTML = i + &apos ...

saving numeric values and text to a document using node.js

In my node.js application, I am working with files to read and write numbers and strings. Currently, I am using fs.writeFileSync(myPath, value); where the value can be either a number or a string. When I try to read the file using fs.readFileSync(myPa ...

How can I configure a unique error log format in Winston?

I am facing an issue with the default error log format in Winston, as it includes too much unnecessary information such as date,process,memoryUsage,os,trace. How can I remove these unwanted details from the log? logging.js const express = require('e ...

Utilizing VueJS and Lodash: The technique for extracting an array of objects exclusively featuring a specific key string

I am attempting to extract certain data from an Object that has a string _new attached to it. Explore the code on Codesandbox: https://codesandbox.io/s/vibrant-bardeen-77so1u?file=/src/components/Lodash.vue:0-353 This is what my data looks like: data.j ...

Personalized customizable elements in Draft.js (extension)

For instance, I am interested in enabling users to incorporate a dynamic slideshow of images into their page using Draft.js. This would allow them to select a predefined slideshow from my app and have it automatically update on their page if the images a ...

What is the proper way to input a valid path?

I am facing an issue with the path to the CSS folder in the linked picture. The HTML code is working fine, but the CSS seems to be not loading correctly. I suspect that the problem lies in the path. How can I rectify this? I'm unsure of what steps to ...

Encountering an issue with Angular's absence while attempting to minify the files

I utilized grunt along with usemin to merge and compress the following code: <!-- build:js /assets/vendor.js --> <script src="../public/bower_components/angular/angular.min.js"></script> <script src="../public/bower_components/angular ...

How to send arguments to an external JavaScript file with JavaScript

In the header of my HTML document, I have included the following script: <script src="http://www.domain.com/js/widgets.js" type="text/javascript"></script> This script references: widgets.js (function () { var styleEl = document.create ...

Vue3 - Implementing a seamless communication channel between two child components

Vue 3 has brought about changes in my component structure, as shown below: https://i.sstatic.net/bgtPB.png In this setup, ChildA can communicate with ChildB and requires ChildB to update its state accordingly. In Vue 2, I could send an event from ChildA: ...

The React hook is activated each time a key is pressed, but it should ideally only be triggered when there is

I have created a hook for my Formik form that should be called whenever a specific field's Selection option is chosen. However, I am facing an issue where the hook is being triggered on every key press in every form field. I am not sure what mistake ...

Encountering module error 'internal/fs' after updating to Node 7

We have encountered some challenges after attempting to update our build server to node v7.0.0. Specifically, the application build task fails at the "bower_concat" step with the following error message: Loading "bower-concat.js" tasks...ERROR Error: Cann ...

The v-on:click event handler is not functioning as expected in Vue.js

I am currently learning vue.js and facing some challenges. Below is the code snippet from my HTML page: <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="https://cdn.jsdelivr.net ...

Tips for switching a group of buttons within a userscript by clicking a single button?

Apologies if my wording is not clear, allow me to clarify. I am in the process of developing a userscript that will display a set of buttons below a main button when clicked. These additional buttons will serve different functions and should disappear whe ...

JavaScript - Ensure all special characters are maintained when using JSON.parse

I have encountered an issue while running a NodeJS app that retrieves posts from an API. The problem arises when trying to use JSON.parse on text containing special characters, causing the parsing process to fail. Special characters can include symbols fr ...

Graphical Interface for an HTTPAPI

After successfully building a REST API in Node.js using Express that includes queue functionalities, my next goal is to develop a web interface for this API. As a newcomer to JavaScript and Node.js, I would greatly appreciate any advice or guidance on ho ...

What is the best way to confirm the validity of an email address?

With jQuery Tag-It, I want to validate the tag value as a valid email address. How can I achieve this validation using tag-it? ...