Mastering CSS for Smoothly Animated Dynamic Height Adjustments

I have a web page with a wizard containing three steps.

Transitioning from step 1 to step 2 causes the content in step 2 to push the content in step 1 down. Moving from step 2 to step 3 flips over to display the content in step 3, concealing the content in step 1 and 2. The working example can be seen in this Bootply. Below is the code:

<div class="container-fluid" style="background-color:#eee;">
  <div class="container">
    <div class="flip-container">
      <div class="flipper">
        <div class="front">
          <div class="step-2-default" id="step2" style="overflow-x:hidden; padding:0.0rem 1.0rem;">
            <label>Step 2</label>
            <p>Details of the second step</p>
            <button id="nextButton2">next</button>        
          </div>

          <div class="step-1-default" id="step1">
            <label>Step 1</label>
            <p>Details of the first step</p>
            <button id="nextButton1">next</button>
          </div>
        </div>

        <div class="back">
          <div id="step3">
            <label>Step 3</label>
            <p>Thank you for using this wizard</p>
          </div>                                
        </div>
      </div>
    </div>
  </div>
</div>

The initial issue is the background-color set to #eee, which is not appearing due to the height being 0. The goal is to adjust the div size based on the front class's height. Essentially, ensuring the div matches or exceeds the front div's height. This dynamic adjustment should accommodate the growth when step 2 reveals itself.

If anyone knows how to address this challenge, please share your insights!

Answer №1

When setting the height of .front and .back to 100%, it's important to clarify what that percentage is referring to. Consider specifying the height in pixels or using 'auto' for dynamic content. The latter option is recommended for flexibility.

.front, .back {
  width: 100%;
  height: auto;
}

Check out the demo here

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

Link Google Map Marker Click Event with Dynamic Binding

I'm currently working on binding a click event to a link that is positioned outside the Google Map Canvas. The goal is to open an "infowindow" on a map marker when this link is clicked. While I know how to achieve this for a specific point, I need a d ...

Is it possible to change the tab name in Materialize CSS?

Hey there amazing people of the internet, hope you're all doing fantastic. I'm currently working on a project that requires me to implement Materializecss framework's tab element. What I want to achieve is allowing users to edit the name of ...

Update JavaScript variable value when there is a change in the onchange

Greetings, thank you for taking the time to read this. I am currently working with an input that includes a datepicker calendar. This calendar has variables called minDays and MaxDays which allow users to select a specific number of days. In my HTML form, ...

Passing multiple arguments to a callback function in node-js without using promises

Within my small program, I am working on unshortening a URL and then verifying if the link adheres to a specific pattern. If it meets the criteria, I aim to carry out additional processing steps. However, I find it cumbersome to pass along all 3 paramete ...

Create the key's value in a dynamic manner within localforage

When utilizing localForage to store data offline, I encountered an issue with generating unique key values for each form submission. My goal is to have the key value generated dynamically as 'activity_1', 'activity_2', 'activity_3& ...

Fine Uploader - Using Form Submission Instead of AJAX

Currently, I am using the Fine Uploader on my webpage to upload files to a server via AJAX. However, I would like the functionality to be similar to a traditional HTML Input File and Input Submit so that I can access $_FILES in the new response. Is it fea ...

What are some techniques for styling a field when the div id is not specified?

I need to customize a data field within a table, but I am unable to locate or identify its div ID. Here is the page source: <tbody> <tr> <td style="font-size:12px; text-align:center;" name=""> <div sty ...

Transitioning from es2016 to es2018 or later versions may cause fakeAsync tests to encounter failures

I have been working on upgrading my project and wanted to make sure I was using the latest ECMAScript version. In my tsconfig.spec.json files, I originally had es2016, but I decided to try updating it to 2018 and even experimented with es2022. After chan ...

Nav links in Bootstrap are seriously misplaced

My navigation bar, created with Bootstrap 4 CSS, consists of 3 links and a brand logo. Despite my expectations of all elements aligning properly, they appear disorganized and not in line. Please see the current layout here: https://i.sstatic.net/OeKcf.pn ...

Having trouble retrieving json data from PHP page using jQuery $.ajax

Having trouble accessing this JSON data in JavaScript, as when I try to alert it the result comes back as undefined Below is the jQuery code snippet: $.ajax({ type: "POST", url: "frmMktHelpGridd.php", data: { labNo: secondElement ...

Is there a way to add a scrollbar to the ChartJS tooltip to avoid data

I'm currently working on a chartJS project where I have a callback function to display data in tooltips. However, as the data increases, the overflow section of the tooltip gets hidden from the canvas. Is there a solution to prevent this overflow and ...

Non-IIFE Modules

Check out this discussion on Data dependency in module I have several modules in my application that rely on data retrieved from the server. Instead of implementing them as Immediately Invoked Function Expressions (IIFEs) like traditional module patterns ...

Why doesn't jQuery UI's addClass method animate visibility like it should?

One of the advantageous features of jQuery UI is its enhancement of the jQuery addClass method, which enables animation by including a second parameter for 'duration', as shown below: $('div').addClass('someclass', 1000); Th ...

Convert the JSON data into the specified format using JavaScript

Is there a way to transform JSON data like this in JavaScript? data = [{acquired: "2018-03-09T22:49:52.935Z", mean_ndvi: -0.0483685} {acquired: "2018-02-13T22:49:16.568Z", mean_ndvi: 0.00595065} {acquired: "2018-04-01T22:50:30.912Z", mean_ndvi: -0.033455} ...

Tips for avoiding html entities in a string

To prevent any user-entered content from being interpreted as HTML, I need to escape it so that special characters like < become < in the markup. However, I still want to wrap the escaped content with actual HTML tags. The goal is to ensure that the ...

I am looking to remove identical innerText values from two arrays using JavaScript

Is it possible to use JavaScript to remove the "added" className of an element with the same innerText when the delete button (.btn-wrap>li>button) is clicked? <div class="table"> <ul> <li class="added">l ...

I'm interested in learning about the most efficient practices for handling JSON, performing math operations, and utilizing loops in JS/React. What techniques

Short version: I'm working with a large array of JSON objects (60K+ elements) in my application I need to perform various mathematical operations such as comparison and addition Currently, I am handling this through multiple for loops (simplified ...

If the value is less than 6, change the color of a cell in a different table to red

I am in the process of developing a bike reservation system that collects information from a form and stores it in a database (completed). The stored information is then displayed in a table (completed), with the feature pending to automatically delete dat ...

Is there a way to access the Google Maps instance without the need to define it as a global variable?

When referencing the google map API documents, it is common practice to use script tags which make the google map instance a global variable. But is there a way to access the map instance without it being global? The npm/bower package angular-google-maps, ...

Unable to refund items in the list box

I have been working on a code snippet to retrieve a list of items from a listbox. The listbox can contain any number of 10-digit numbers in multiple rows. However, when I run the code, the "NPIListBox.Items.Count" function only returns a count of 1, even w ...