Tips for preventing the div from disappearing when using rotateY(90deg)

My website features a div element with an animation that gives the illusion of it being flipped over.

<div id="wrapper">
    <div id="content">
        Some content
    </div>
</div>

To achieve this effect, I use the jQuery plugin transit to rotate the "wrapper" div by applying the CSS rule;

transform: rotateY(180deg);

During the rotation, when the div reaches rotateY(90deg), new content is loaded into the #content div. This process happens quickly, but during the animation, the div momentarily disappears or becomes hidden.

VIEW DEMO FIDDLE (Note that the actual content loading is not included in the demo)

I am looking for a way to prevent the entire div from disappearing completely at rotateY(90).

Unfortunately, since the HTML is dynamically generated, I do not have control over it.

https://i.sstatic.net/GIch7.gif

Answer №1

Consider adding some depth to the design by incorporating thickness into it. For inspiration, take a look at this example: want to show the thickness of an element while it rotates

You can achieve the desired effect with CSS animations like this: 0%: transform: rotateY(0deg); 50%: transform: rotateY(90deg); 100%: transform: rotateY(180deg);

Hopefully, this suggestion proves useful in your project.

Ensure that the jQuery plugin includes necessary CSS files or explore alternative options.

Alternatively, consider achieving the effect using basic CSS and jQuery.

Answer №2

Let's keep the div's content intact and split it into two sections:

<div id="container">
    <div class="section-1">
        Some text here
    </div>
    <div class="section-2">
        Some more text here
    </div>
</div>

CSS Styles:

#container{
    transition: all 2s;
    position: relative;
}
#container.flip{
    transform: rotateY(180deg);
}
.section-1{
    z-index: 1;
    opacity: 1;
    position: absolute;
    height: 100%;
    transition-delay: 1s; //half of container transition time
}
.section-2{
    z-index: 0;
    opacity: 0;
    transform: rotateY(180deg);
    position: absolute;
    height: 100%;
    transition-delay: 1s;
}
.flip section-1{
    z-index: 0;
    opacity: 0;
}
.flip section-2{
    z-index: 1;
    opacity: 1;
}

Javascript Functionality:

$('.next-section').click(function(){
    $('#container').addClass('flip');
});
$('.prev-section').click(function(){
    $('#container').removeClass('flip');
});

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

Deactivate Mongoose connection in Node.js after completing tasks

Here is a mongoose script I have been using to connect to the local database and perform some operations. However, I am facing an issue with disconnecting the connection after use. const mongoose = require('mongoose'); const db = mongoose.connec ...

Ajax request not populating controller with data in ASP.NET CORE MVC

`Hello everyone, I'm running into a problem with my colleague's assignment and could really use some assistance. The issue pertains to ASP.NET Core MVC. I have an API Controller for editing student groups. This API Controller receives a GroupView ...

I encountered an error when attempting to integrate Node.js with my terminal in the text editor - permission was denied

After installing node.js and npm, I encountered permission issues when trying to run them from my text editor (VSC). I was advised to open the terminal within the text editor, drag and drop the .js files I'm working on, add "node" and hit "enter" to r ...

Tips for swapping out textures imported from Collada with ShaderMaterial textures in Three.js

Is it possible to update the textures of a basic 3D model loaded using the Collada loader in the Three.js library? My goal is to incorporate color, specular, and normal maps onto the model using ShaderMaterial by referencing new files with the model' ...

Steps to create two jQuery dropdown filters for multiple identifiers:

Is it possible to create two dropdown menus that can be used to filter a gallery of images? I am currently facing an issue where the filtering functionality is not working after adding a name attribute to the image IDs. When I select an option from the s ...

Ways to reduce lag while executing a for loop

How can I optimize my prime number generation process to avoid lagging? For example, is there a way to instantly display the results when generating primes up to 1000? HTML: <!DOCTYPE html> <html> <meta name="viewport" content="width=dev ...

Create a JavaScript JSON object using a for loop

I am working on creating an object similar to this var flightPlanCoordinates = [ {lat: 37.772, lng: -122.214}, {lat: 21.291, lng: -157.821}, {lat: -18.142, lng: 178.431}, {lat: -27.467, lng: 153.027} ]; Here is my attempt so far for (i = 0; ...

Unlocking the JSON array of data in JavaScript: A step-by-step guide

Hey there, I need help extracting an array from a JSON data structure. Here's an example of my JSON object: { Data1 : { Data2 : "hello", Data3 : "hi" }, Data4 : { Data5 : "this is Karan", } } I'm looking ...

disable collapsible effect on checkbox

I have a table where I need to disable the accordion animation for a specific checkbox. The checkbox should function like a normal item. You can see a sample example at https://jsfiddle.net/qxgz4pp8/3/ Below is the JavaScript function I have defined for t ...

Is it possible for a nodejs server to handle both grpc and express servers simultaneously, or do they need to be separate servers?

I'm currently in the process of building a REST server using Node/Express. I'm curious about how to incorporate a GRPC server within the same setup. Would it be possible to run both servers on the same NodeJS instance, or is it recommended to hav ...

Increase the background image size for a <li> element

I am working with an unordered list and have set it up to display a background image on the li element when the cursor hovers over it: <div class="sidebar"> <ul> <li>test</li> <li>test</li> ...

What is the best way to ensure two tables are aligned side by side in a horizontal

I'm facing an issue with two tables on my HTML page that are aligned horizontally - one on the left and the other on the right. They look good when the browser is maximized but lose their horizontal alignment when the window size is reduced. I have ap ...

Troubleshooting Problems with Retrieving Data Using jQuery and

Having trouble fetching information from a JSON file, as the data variable is empty. I have already downloaded the JSON file, so it's not an issue with the server connection. Can anyone point out where I might be going wrong? function handle_geolocat ...

Tailwind custom classes are not being rendered on mobile devices and Chrome DevTools, however, they are functioning properly on desktops and Safari DevTools

During the development of my project using Tailwind CSS, I focused on desktop compatibility and ensured responsiveness with Safari and Google Chrome. However, upon switching to DevTools, I encountered issues that persisted when testing on mobile devices. ...

Basic javascript doesn't trigger

Attempting to create a basic AJAX script for testing PHP functionality. However, experiencing issues as the expected output "here" is not appearing due to an error message regarding event.returnValue being deprecated in Chrome. Any insights on what may be ...

Repetitive submissions of a form through Ajax post requests

Currently, I am utilizing this code to handle data sent via Ajax. Within the code, I am using the summernote editor. However, I have encountered an issue where if I submit the form while missing a required field, the form displays a 'required alert&ap ...

Order of stacked divs with absolute positioning

I'm struggling to make a photo expand when hovered over without it expanding under the existing content. My current HTML and CSS code is as follows: .userCard {width:360px;height:180px;border:1px solid black;float:left;margin:10px;position:relative ...

What causes the table to expand with new cells once the database information is shown?

I'm confused as to why an empty cell is being added to the right even if there is data from the database to display. This particular code is meant to showcase a school schedule. Attached is a picture showing how it currently appears. Below is the PH ...

Looking for guidance on how to fill the "via" table in Sequelize?

I'm currently trying to understand the N:M relationship in sequelize, specifically regarding populating the "through" table. Here are the models I am working with: Product / Category 'use strict'; module.exports = (sequelize, DataTypes) = ...

Develop a function that transforms a provided string

I need assistance creating a function that will convert a given string into the specified output format shown below: // Input const optionRule = '{1069} AND ({1070} OR {1071} OR {1072}) AND {1244} AND ({1245} OR {1339})'; // Output Example /* co ...