Spinning with animation in jQuery

Greetings! I am in the process of creating a popup box that will appear upon clicking the Login button. My aim is to produce a popup box with a rotating effect, however, my attempts have not been successful so far. You can view the code snippet on JsFiddle or take a look at the code provided below.

SCRIPT

$('.login').click(function(){
    $('.loginWrapper').css('display','block');
  /*Trying to do something like this

  $('.loginBox').animate(function(){      
          transform: 'rotateX(-60deg)'
          })

  */
});
HTML

<button class="login">Login</button>
<div class="loginWrapper">
  <div class="loginBox loginRotate"> <img src="images/Cancel.png" width="32" height="32" alt=" " class="cancel">
    <h2>Login</h2>
    <form name="form1" method="post" action="">
      <input type="text" name="" id="" value="Email ID" onblur="if (this.value=='') this.value = this.defaultValue" onfocus="if (this.value==this.defaultValue) this.value = ''">
      <input type="password" name="" id="" value="Password" onblur="if (this.value=='') this.value = this.defaultValue" onfocus="if (this.value==this.defaultValue) this.value = ''">
      <div class="forgotPassword"><a href="#">Forgot password?</a></div>
      <input name="" type="submit" value="Login">
      <div class="forgotPassword">Don't have an account? <a href="#">Get in touch</a> with our Sales team.</div>
    </form>
  </div>
</div>
CSS

.blksheet {
background: url(../images/blkSheet.png);
height: 100%;
width: 100%;
position: fixed;
z-index: 9999999;
display:none;
}
.loginWrapper{
position: fixed;
width: 400px;
-webkit-perspective: 500px; /* Chrome, Safari, Opera */
perspective: 500px;
top: 40%;
left: 40%; 
z-index: 99999999;
display:none;
}
.loginRotate{
-webkit-transform: rotateX(-60deg); /* Chrome, Safari, Opera  */
transform: rotateX(-60deg);}
.loginBox {
background: #fff;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
transform-origin:50% 0 0;
padding: 13px 20px;
font-size: 1em;
-webkit-box-shadow: 0px 0px 13px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 0px 13px 0px rgba(0,0,0,0.75);
box-shadow: 0px 0px 13px 0px rgba(0,0,0,0.75);
}
.loginBox .cancel {
position: absolute;
right: -18px;
top: -18px;
cursor: pointer;
}
..... (CSS continues)

Answer №1

If you want to achieve this effect, you can utilize css-transitions along with the transform-rotate property:

JS

$('.loginRotate').css({
    '-webkit-transform': 'rotate(0deg)',
    'transform': 'rotate(0deg)'
}); 

CSS

.loginRotate{
    -webkit-transform: rotateX(-60deg);
    transform: rotateX(-60deg);
    -webkit-transition: 0.5s ease -webkit-transform;
    transition: 0.5s ease transform;
}

An effective approach would be to create a separate class for these parameters

JS

$('.loginRotate').addClass('spot');

CSS

.loginRotate.spot {
    -webkit-transform: rotate(0deg),
    transform: rotate(0deg)
}

Check out the updated fiddle here: http://jsfiddle.net/Km5GL/2/

Answer №2

If you're looking for a useful plugin to meet your requirements, this one might be just what you need.

Check out this link for more information: http://louisremi.github.io/jquery.transform.js/

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

Implementing Bootstrap 4 validation within a modal using JSON data

I've been struggling to validate the TextBoxFor before submitting the form. Despite trying various methods, I haven't managed to make it function properly. Modal: <div class="modal fade" id="MyModal_C"> <div class="modal-dialog" st ...

Set the value of a hidden field and proceed to submit it in CodeIgniter

I seem to be struggling with a simple task of setting a hidden input value. Here is how my form is structured: <?php echo validation_errors(); ?> <?php echo form_open('purchasing'); ?> <h1>Purchasing Re ...

Challenge with cloning Jquery datepicker

I am struggling to implement the datepick() functionality for newly created items. Everything works perfectly fine except for this issue. The first elements, named date1 and datep1, have datepick functionality and work well. I have obtained the plugin f ...

Using JQuery to make AJAX requests and parse XML data involves

I'm currently facing a challenge while attempting to parse XML using jQuery. Despite following a well-established function, there seems to be an issue with the ajax component. No matter what I do, it keeps skipping this crucial part. It's puzzlin ...

Step by step guide on incorporating two background images in a single header

I'm looking to create a header with a background image that appears twice, like this: To achieve the effect, I added opacity of 0.5 to one of the images, but it is affecting everything in my header including text and logo. Is there a way to prevent t ...

Conditionals in Angular 2 using Sass

Looking to apply this style with Sass or CSS: IF :host.form-control MATCHES .ng-valid[required] OR .ng-valid.required THEN :host ::ng-deep input.form-control = border-left: 5px solid #42A948; Appreciate the help! ...

Adjustable background image with no need for a scroll bar

I am looking to create a static webpage that remains fullscreen without any scrolling. My goal is to have a centered form with the background image adjusting to the window size. As a beginner, I apologize if this request seems too simple. .container { ...

Having difficulty sizing specific <td> elements in an HTML table

Is there a way to increase the size of a TD cell without adjusting the height of the entire row? I tried using inline styling with "rowspan= 7", but it only centers the data in the middle of the cell. I am attempting to create a table similar to the one s ...

The issue I am facing is that the "return false" statement does not seem to be effective in my jQuery AJAX

Apologies to everyone.. :( it seems I missed including the jquery library... My bad! :3 Feeling quite exhausted at the moment. Could someone please point out what's wrong with my code? The 'returning false' isn't functioning as expecte ...

Guide to customizing color themes using Twitter Bootstrap 3

Recently, I dove into the world of Twitter Bootstrap 3 without any prior experience with earlier versions. It's been a learning curve, but I managed to set up a WordPress theme using it as the framework. All my elements are in place, but they all see ...

Toggle the visibility of a div depending on the user's selection

My HTML select element has a few options to choose from: <select class="form-control" data-val="true" data-val-number="The field CodeSetup must be a number." id="CodeSetup" name="CodeSetup"> <option selected="selected" value="0">AllCodes< ...

Leveraging JQueryUI for an audio Seek feature, and dynamically connecting a fresh slider to the <audio> element whenever a song is swapped out

Thanks for taking a look at my question. The code snippet can be found HERE. I'm in the process of creating an audio player to handle multiple songs on a single page using JQueryUI Slider and HTML5 Audio, with one Audio element and several sliders. ...

I can't seem to figure out the source of this unexpected padding/margin on my website

After creating a website for a church using Foundation, SASS, and Compass, I noticed a horizontal scroll issue when resizing the window. Adding overflow-x: hidden; seemed to fix it, but there was still about 20px of padding on the right side when testing ...

Divs aligned horizontally with uniform height and vertical divider separating them

Seeking a method to create side by side, equal height divs (without resorting to table layout) with a single vertical line separating them. Attempted using flex container per row but the vertical line is fragmented which is not ideal... What would be the o ...

Conceal the unstyled element and reveal its adjacent sibling?

I have come across some HTML code that I am unable to modify. Instead of using JS/jQuery, I prefer a solution with cross-browser compatible CSS. The structure of the HTML is as follows: <ul class="list"> <li class="item"> <a hr ...

Utilizing jQuery to retrieve data from a JSON object with a nested array

After making an API call to Google Translate, the following data was returned: { "data": { "detections": [ [ { "language": "en", "isReliable": false, "confidence": 0.051902372 } ] ] } } In order to access the "language" ...

The flash movie covers part of the menu that is relatively positioned

While designing a website, I encountered an issue with the Flash slider (CU3ER) overlapping the menu bar. Despite trying various z-index configurations to ensure the drop-down menu stays on top, none of them seem to work. Initially, the drop-down menu rem ...

Aligning MaterialUI Grid items vertically within various Grid containers

Looking to implement a design that features three vertical columns. The first and last columns will display MaterialUI cards, while the middle column will showcase a vertical line with dots aligned vertically with the start of each card. The height of the ...

Ensuring Valid Submission: Utilizing Jquery for a Straightforward Form Submission with 'Alajax'

After searching for a straightforward JQuery plugin to streamline the process of submitting forms via Ajax, I stumbled upon Alajax. I found it quite useful as it seamlessly integrates into standard HTML forms and handles all the necessary tasks. However, I ...

Exploring the use of jQuery/JS for parsing and working with JSON

Hi everyone, I need some assistance with displaying data from an array created by a PHP file using JS/jQuery. Currently, I am working on implementing a points system for ZetaBoards which you can check out here. The points will be shown below the user' ...