Creating engaging animations for variable content in Safari using CSS

This multi-step wizard is designed to smoothly transition between its 3 steps. Upon clicking the "next" button in step 1, the content is pushed down to reveal step 2. Similarly, when advancing from step 2 to step 3, the contents of both previous steps are flipped over to display the final step.

While I have achieved success with animating card flips in Safari using absolute heights and dynamic container growth, combining these two functionalities has proven challenging specifically in Safari. The behavior works seamlessly in Chrome and Firefox, as illustrated in this Bootply.

<section class="container">
    <div id="card">
      <figure class="front">
        <div class="step-2-default" id="step2" style="overflow-x:hidden; padding:0.0rem 1.0rem;">
          <label>Step 2</label>
          <p>These are the details of the second step</p>
          <button id="nextButton2">next</button>        
        </div>

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

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

Although the card flip functionality is working in the provided Bootply, the challenge lies in getting the container background to properly render and expand along with the growing card. Absolute heights cannot be utilized due to dynamic content within each step.

I welcome any assistance or suggestions on resolving this issue for a seamless experience across all browsers, particularly in Safari.

Answer №1

I believe we can simplify this by just adding a border to the card figure element:

#card figure {
    border: 10px solid #808080;
    display: block;
    height: auto;
    width: 100%;
    color: #fff;
    text-align: center;
    font-weight: bold;
    position: absolute;
    -webkit-backface-visibility: hidden;
    -moz-backface-visibility: hidden;
    -o-backface-visibility: hidden;
    backface-visibility: hidden;
}

http://www.bootply.com/7Q9RMtpv3F

Answer №2

After some thought, I believe I've found the solution to this issue. While I will provide a snippet later on, the concept involves inserting a spacer div with a margin height before the first card and after the last card. By setting the container height to auto, your problem should be resolved.

UPDATE: The fix is in place now. Check out the working fiddle provided below.

Here's the revised HTML structure:

window.onload = init()
function init(){

    var card1 = document.getElementById('card-1')
    var card2 = document.getElementById('card-2')
    var card3 = document.getElementById('card-3')

    card2.style.display = 'none'
    card3.style.display = 'none'

    function addButton(el){

        var newButton = document.createElement('button')
        var buttonAttribute = document.createAttribute('id')
        
        buttonAttribute.value = 'next-button'
        newButton.setAttributeNode(buttonAttribute)
        newButton.textContent = 'Next'

        el.appendChild(newButton)

        return newButton
    }

    var nextButton = addButton(card1)

    nextButton.addEventListener('click',function(){

        this.parentElement.removeChild(this)
        var nextButton = addButton(card2)

        card2.style.display = 'block'
        nextButton.addEventListener('click',function(){

            card3.style.display = 'block'
            card3.style.display = 'flip2 1.5s ease-in-out 0s forwards'
            container.style.animation = 'flip 1.5s ease-in-out 0s forwards'
        })

    })

}
*, html, body{box-sizing: border-box; color: white;}
html, body{margin: 0;}
#container{
    width: calc(200px + 20px);
    height: auto;
    background: grey;
    position: relative;
    margin: auto;
    -webkit-perspective: 800px;
    -moz-perspective: 800px;
    -o-perspective: 800px;
    perspective: 800px;
}
.space{height: 10px}
.card{
    background: red;
    height: 140px;
    width: 200px;
    margin-left: auto;
    margin-right: auto;
    padding: 5px;
    -webkit-backface-visibility: hidden;
    -moz-backface-visibility: hidden;
    -o-backface-visibility: hidden;
    backface-visibility: hidden;
}
#card-3{
    background: blue;
    top: 10px;
    left: 10px;
    height: 280px;
    position: absolute;
    -webkit-transform: rotateY( 180deg );
    -moz-transform: rotateY( 180deg );
    -o-transform: rotateY( 180deg );
    transform: rotateY( 180deg );
}

@keyframes flip{
    0%{
        -webkit-transform-style: preserve-3d;
        -moz-transform-style: preserve-3d;
        -o-transform-style: preserve-3d;
        transform-style: preserve-3d;
        -webkit-transform: rotateY( 0deg );
        -moz-transform: rotateY( 0deg );
        -o-transform: rotateY( 0deg );
        transform: rotateY( 0deg );
    }
    100%{
        -webkit-transform-style: preserve-3d;
        -moz-transform-style: preserve-3d;
        -o-transform-style: preserve-3d;
        transform-style: preserve-3d;
        -webkit-transform: rotateY( 180deg );
        -moz-transform: rotateY( 180deg );
        -o-transform: rotateY( 180deg );
        transform: rotateY( 180deg );
    }
}

@keyframes flip2{
    0%{
        -webkit-transform-style: preserve-3d;
        -moz-transform-style: preserve-3d;
        -o-transform-style: preserve-3d;
        transform-style: preserve-3d;
        -webkit-transform: rotateY( 0deg );
        -moz-transform: rotateY( 0deg );
        -o-transform: rotateY( 0deg );
        transform: rotateY( 0deg );
    }
    100%{
        -webkit-transform-style: preserve-3d;
        -moz-transform-style: preserve-3d;
        -o-transform-style: preserve-3d;
        transform-style: preserve-3d;
        -webkit-transform: rotateY( 180deg );
        -moz-transform: rotateY( 180deg );
        -o-transform: rotateY( 180deg );
        
}
<div id="container">

    <div class="space"></div>

    <div id="card-1" class="card">
        <p>Step 1</p>
        <p>These are the steps of step one</p>
    </div>
    <div id="card-2" class="card">
        <p>Step 2</p>
        <p>These are the steps of step two</p>
    </div>
    <div id="card-3" class="card">
        <p>Step 3</p>
        <p>This is the end</p>
    </div>

    <div class="space"></div>

</div>

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

Steps for making a grid within a bootstrap 3 modal

I am new to HTML and CSS I'm working on creating a modal content similar to this: https://ibb.co/RvrhmRs Most of the work is done, but my modal currently looks like this: https://ibb.co/1zG0y2t I just need help arranging an icon next to the text. ...

What is the process for transforming a string into a dictionary using jinja2?

I have a variable called {{data}} which contains a string formatted like this: *{"a": "1", "b": "2", "c": 3, "d": 4}* My goal is to access the values in this format: *{{data.a}} --> 1 {{data.b ...

What is the best way to retrieve all the listed TV and film ratings in descending order? Using Django

Our Goal I aim to organize movies based on their star ratings and filter out those with ratings lower than a specified threshold. 2. Retrieve the IDs of Movies and TV shows mentioned in the view, fetch the data and score through URLs one by one. 3. Presen ...

The function of jQuery .click() not triggering on elements within msDropDown

I'm having difficulty implementing jQuery on an Adobe Business Catalyst site. The HTML snippet below shows the structure: <div class="banner-main"> <div class="banner-top"> <section class="banner"> <div class="catProd ...

Bottom section of a multi-level website with horizontal dividers

I was struggling with aligning divs next to each other, but I managed to find a solution. The only issue is that the text now aligns to the right instead of going below as it should. Typically this wouldn't be an issue since all content is within the ...

What is the proper method for attempting to implement Response.Redirect?

Is there a better way to handle redirect failures than using a try-catch block? Typically, a redirect always throws an exception which can be caught as a ThreadAbortException. However, is this the most effective approach? EDIT: My goal is to redirect to ...

"Utilizing FileReader to seamlessly integrate data into FormData without the risk

Currently, I'm in the process of constructing an ajax file uploader. This is made possible thanks to the recently introduced FormData interface. Everything seems to work as expected when using the original file. However, I encounter issues when conver ...

Receiving a NaN output rather than a numerical value

Experiencing what seems to be a straightforward syntax error, but I'm unable to pinpoint it. Controller: $scope.startCounter = 3; $scope.startTimeouter = function (number) { $scope.startCounter = number - 1; mytimeouter = $t ...

Extracting data from a dropdown list with beautifulsoup

Could someone please assist me in scraping a list of dates from: The dates can be found within a dropdown menu just above the option chain. I have experience scraping text from websites, but this specific text is utilizing 'select' & 'o ...

Responsive column display on mobile devices can be optimized by configuring columns to appear in a 2x3 or 1x6 layout. This can be achieved even with

Currently utilizing the Avada Fusion Theme, my ability to edit core theme HTML files is limited. Fortunately, I do have access to Custom CSS. The challenge I am facing involves adjusting the display of the columns to appear as 2x3 instead of 1x6 on mobil ...

How do I resolve the issue of unable to align the element correctly?

I am struggling to create a hamburger menu icon and align it using flexbox. Unfortunately, the icon is not aligning properly as it is going beyond the menu and the browser screen with an odd top indent. Below is the code I have written: * { margin: 0 ...

having each individual div function on its own accord

Is there a more efficient way to make HTML and CSS function independently without duplicating the code multiple times and changing IDs or class names? Currently, only the top male and female button works when clicked. I am looking for a CSS-only solution t ...

Code an AJAX login form using PHP, HTML, CSS, jQuery, and MySQL

I'm struggling with the login functionality on my website. Despite entering correct details, users are unable to log in using their name and email ID. As a beginner in using Ajax, I need guidance on how to troubleshoot this issue. What steps should I ...

What steps should I follow to create a cohesive background design using CSS?

https://i.sstatic.net/e3LYL.png Is there a way to combine two separate div elements in CSS? Currently, the image Row and col are not connected to the above SVG blob. How can I utilize the blob as a background? Based on the code provided below, they appear ...

What is the reason for the absence of absolutely positioned elements in the render tree?

Recently, I came across some information about the render tree: As the DOM tree is being created, the browser simultaneously generates a separate tree known as the render tree. This tree consists of visual elements arranged in the order they will ap ...

The necessary min-width for the media query has not been implemented

Despite creating a basic example using media queries, I'm puzzled that the effect is not being applied at the exact min-width, but rather at (offset + min-width). The HTML document is currently empty. <!DOCTYPE html> <html lang=""> <h ...

DIV height adds a layer of design to a website, making it visually

I have a situation where one of my web pages contains a DIV element with text inside, set at 1.1em size. Here's an example: <div id="displaydiv"> <b>Hello World</b> </div> On another page, I have the same DIV element but ...

Show only a cropped section of a resized image within a div

I have a script that calculates the best region of an image to display within a specific div size. This calculation is done in PHP and generates a JSON output like this: {"scale":1.34,"x1":502,"x2":822,"y1":178,"y2":578} The image in question has dimensi ...

The express-handlebars module is having trouble parsing HTML within the main layout file in an Express.js application

Hello, I am facing an issue with handlebars as it is not reading the HTML in my file. Here is a screenshot highlighting the problem along with the provided code. The folder structure is as follows: views layouts main-layout.hbs home.hbs https://i ...

Modifying an image's src using JavaScript is not possible

I'm attempting to modify the source of an image using a JavaScript function, but it doesn't seem to be working. The function is being executed within a mounted() method in Framework7. Here is my current setup: HTML: <div> <span> &l ...