rotate elements with CSS3 and jQuery

I am attempting to create a flip page using jQuery and CSS3. I have managed to achieve it by placing my two pages in one container and rotating the entire container, but I would like to rotate the pages individually. Here is the code I currently have:

CSS:

#pagecontainer {
    position: absolute;
    width: 100%;
    height: 100%;
}

.page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
    -webkit-backface-visibility: hidden;
    -moz-backface-visibility: hidden;
    -o-backface-visibility: hidden;
    backface-visibility: hidden;    
}
.back {
  -webkit-transform: rotateY(180deg);
  -moz-transform: rotateY(180deg);
  -o-transform: rotateY(180deg);
  transform: rotateY(180deg);
}

.flip.out {
    -webkit-transform: rotateY(180deg);
    -moz-transform: rotateY(180deg);
    -ms-transform: rotateY(180deg);
    -o-transform: rotateY(180deg);
    transform: rotateY(180deg);
    -webkit-transform-style: preserve-3d;
    -webkit-transition: all 1.0s linear;
    -moz-transform-style: preserve-3d;
    -moz-transition: all 1.0s linear;
    -o-transform-style: preserve-3d;
    -o-transition: all 1.0s linear;
    transform-style: preserve-3d;
    transition: all 1.0s linear;
 }

.flip.in {
    -webkit-transform: rotateY(0deg);
    -moz-transform: rotateY(0deg);
    -ms-transform: rotateY(0deg);
    -o-transform: rotateY(0deg);
    transform: rotateY(0deg);
    -webkit-transform-style: preserve-3d;
    -webkit-transition: all 1.0s linear;
    -moz-transform-style: preserve-3d;
    -moz-transition: all 1.0s linear;
    -o-transform-style: preserve-3d;
    -o-transition: all 1.0s linear;
    transform-style: preserve-3d;
    transition: all 1.0s linear;
 }

Following this, I apply these classes to my pages within the page container:

container.append(nextPage);
nextPage.attr("class", "page back");
currentPage.one('webkitTransitionEnd', function(e) {
    currentPage.remove();
});
nextPage.attr("class", "page back flip in");
container[0].offsetWidth;
currentPage.attr("class", "page flip out");

However, only the front page is flipping. What could be the issue?

EDIT: I managed to solve it. I needed to adjust the order in my script. It should be:

currentPage.attr("class", "page flip out"); <-- Start with this 
container[0].offsetWidth;
nextPage.attr("class", "page back flip in"); <-- End with this

Answer №1

Check out this awesome plugin and its source code here. Also, keep in mind that even IE10 does not support preserve-3d rendering.

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

Toggle between displaying and concealing content by clicking or hovering the mouse

I have a button that is positioned at the top of the browser. I want to show a dropdown list when the user clicks or hovers over this button. HTML <div class="translator"> <div class="translate-btn">Translator</div> <div class="t ...

Creating dynamic dropdown menus using PHP and jQuery

I'm struggling with sending and reading an ajax variable. My current Ajax code looks like this: $.ajax({ url: "/wp-content/themes/canvas-child/get-clients-dropdown.php?it=1", success: function(data) { $("#ClientID").html(data); } ...

tips for creating a jquery/css scales animation

I am looking to implement a unique feature on my website where I create scales with a balancing effect. The scales should mimic an up and down motion continuously. You can see an example of what I'm referring to here Is there a way in jQuery or CSS t ...

Provide Jquery with a named function for success plus some extra perplexity

Can anyone help me figure out why my JQUERY .ajax request won't accept a non-anonymous function in the success condition? I prefer not to use anonymous functions because I find them harder to debug and read. I've also heard that breaking out fun ...

The webpage freezes when attempting to run jQuery with Selenium

I'm currently facing an issue where my selenium script hangs the webpage whenever I try to find an element using jQuery. The script doesn't execute and a pop up appears in the browser with the message "A script on this page may be busy, or it may ...

Creating a dynamic view using AJAX to track and monitor user activity

I am having trouble with the Django By Example tutorial when it comes to following users. I have been clicking the follow button but nothing happens. I have reviewed that section multiple times, even copied and pasted the code, but it still does not functi ...

JavaScript Slider for Web Browsers and More

I am facing an issue with the slider on my website HERE. The slider seems to be working fine in Firefox, but in other browsers, the slider is extending all the way to the right side of the page. My friends suggested that I remove 'overflow: hidden;&ap ...

Positioning the navbar in the center with Bootstrap 4 using Flexbox

My goal is to achieve the following using the Bootstrap 4 Navbar: I am looking to center the nav-links/items in the middle of the viewport using flexbox or .mr-auto utilities. I prefer to avoid a CSS-based positioning approach as it may not be consistent ...

Is it possible to determine the status of a checkbox if it does not contain the "checked" attribute?

I've been struggling to determine the state of a checkbox using Selenium Webdriver or Javascript, and despite extensive research, I still haven't been successful. My issue is: the checkbox does not have a "checked" attribute: <input type="ch ...

Identify the presence of <br /> within a string and envelop the text with <p>

Can a string in JavaScript be parsed to wrap text blocks separated by 2 <br /> tags with opening and closing <p> tags instead of paragraph breaks? Here is an example text: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec od ...

Tips for sending information to a Flask application using a form and Ajax request

I am currently working on developing a Flask application that will display data scraped from a website. To achieve this, I have imported my scraping file into Flask. In order to perform the scraping function, I need to pass a search query as a parameter. M ...

Delete the content on a webpage using an Ajax jQuery request to transfer it elsewhere

Whenever I submit a form using an ajax post request, I receive values from the controller and manipulate the page based on those values. However, my issue is that I need to erase the values from the previous request when the form is submitted again. For in ...

Struggling with converting my menu design into a dropdown menu

Recently completed creating my initial menu with a left navigation bar design. Wondering if it is achievable to implement a dropdown effect on hover without the use of javascript? I have come across several solutions but they do not seem to work for me, po ...

Access your account and sign up all in one place with the combined Login and Register form on Laravel

I am facing an issue with my login and register page where errors appear for both forms when I fill the register page with wrong credentials. How can I resolve this problem using a Submit button onclick event and hide the login page? Open to alternative su ...

Unable to get Ajax call to function within Flask framework when utilizing Bootstrap model

Struggling with integrating bootstrap modals in a Flask app, specifically when loaded via ajax calls. The process involves loading modal content in two steps and then managing the outcomes. Upon clicking a link - A jquery event binds to make an ajax ca ...

Occupying room while using display: none in <td>

As a newcomer to media queries and .net, I find myself struggling with the code below. At max-width 775px, my goal is to have the first td disappear completely and be replaced by the second td. However, it seems that while the first td becomes 'invisi ...

How to Create Smooth Transitions for Text Arrays using jQuery's Fade In and Fade Out Features

I need to loop through an array of text and apply jQuery's fadeIn and fadeOut functions to each element. var greetings = ["hi, I'm", "bonjour, je m'appelle", "hallo, ich heiße"] The HTML structure I want is as follows: <h2><span ...

Using JQuery to link a single callback function to multiple elements

To restrict users from entering letters in numeric fields, I have implemented the following code: $('input[name=myinput]').live('keyup', function() { var $th = $(this); $th.val($th.val().replace(/[^0-9, ...

CSS rules must include specified units

I am fairly new to CSS and have a question about specifying units in the code below. Without specifying units for height and width, the text fits on one line. However, once I add 'px', the text occupies two lines instead. Can anyone explain what ...

The alert dialog does not appear when clicking on "a"

Attempting to retrieve the ID of the clicked element using jQuery has proven unsuccessful for me. Below is the jQuery code I am working with: <script> $(function(){ $("a.step").click(function(){ var id = $(this).attr('id'); ...