Jumping panel.css transition

I'm trying to create a simple bounce card animation, but I've run into an issue where the animation resets and doesn't flow smoothly.

Could you take a look at this code snippet:

    div{
      width: 110px;
      height: 50px;
      background: #EEE;
      border: 1px solid #BBB;
      border-radius: 3px;
      padding: 3px 5px;
      font-family: sans-serif;
      left: 200px;
      position: absolute;
    }
    
    @keyframes cardBouncing {
    
      20%, 60%, to {
        transform: rotate3d(0, 0, 1, 80deg);
        transform-origin: top left;
        animation-timing-function: ease-in-out;
      }
    
      0%, 40%, 80% {
        transform: rotate3d(0, 0, 1, 60deg);
        transform-origin: top left;
        animation-timing-function: ease-in-out;
      }
    }
    
    div{
      box-shadow: 3px 3px 10px grey;
      animation: 1.5s cardBouncing infinite; //flipInX;
    }
<div>Hello!</div>

  1. Any suggestions on how to make it bounce without that awkward "jump"?
  2. This is intended for a drag animation - how can I center it on the mouse cursor position? Currently, it seems to veer too far to the left. Is there a way to adjust this?

Answer №1

The answer lies in using:

animation-direction: alternate-reverse;

div{
  width: 110px;
  height: 50px;
  background: #EEE;
  border: 1px solid #BBB;
  border-radius: 3px;
  padding: 3px 5px;
  font-family: sans-serif;
  position: absolute;
  left: 180px;
}

@keyframes cardBouncing {
  from {
    transform: rotate3d(0, 0, 1, 60deg);
    transform-origin: top left;
    animation-timing-function: ease-in-out;
  }

 to {
    transform: rotate3d(0, 0, 1, 80deg);
    transform-origin: top left;
    animation-timing-function: ease-in-out;
  }
}

div{
  box-shadow: 3px 3px 10px grey;
  animation: 0.4s cardBouncing infinite;
  animation-direction: alternate-reverse;
}
<div> Hello! </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

What is the point of the horizontal scroll bar in WP Thesis?

There seems to be a horizontal scroll bar appearing at the bottom of my site, even though there is no content extending beyond the visible area. Can anyone provide guidance on how to fix this issue? My website is built on Wordpress 3.0 and utilizes the Th ...

What causes the <td> element to extend beyond the boundaries of the <table>?

I need to add next and previous buttons to a <td> that has an asp:DropDownList. However, when I do this, the <td> ends up overflowing the width of the table. Here is the edited code snippet with the entire table included: <table class=" ...

Maintain the collapsing of links in the navbar with the help of Bootstrap

Currently, I am designing a responsive navigation bar utilizing Bootstrap. The current layout displays as follows: https://i.sstatic.net/KglsX.png in expanded view, and: https://i.sstatic.net/DKvex.png in collapsed view. While the design appears satis ...

Is there a way to dynamically set the width in CSS based on the width of characters used?

The value of rem is based on font height. Therefore, when setting width in rem for layout or media query purposes, it is determined by the height of the characters, not the width. I believe this may not be ideal for creating layouts. ...

Having trouble identifying the source of the margin-right styling being used

I'm facing a perplexing issue with the CSS for my sidebar (#primary) on my website. Even though I haven't specified any margin for the sidebar, it is somehow getting a margin-right of 605px. In trying to solve this, I experimented with relative ...

What is the best way to restrict user input to specific numbers only?

I have a text input field, how can I ensure that only numeric values from 1 to 31 are allowed? <input type="number" min="1" max="31"> ...

Adaptable arrow-shaped progress bar featuring sleek transparent borders

I am currently working on creating a progress bar similar to those commonly found in checkout processes. One issue I have encountered is that the borders between the arrows appear transparent, and the entire design needs to be responsive. So far, I have m ...

The block is not responding to hovering as expected

I'm currently attempting to implement a hover effect for the entire anchor element, but unfortunately it's not functioning as expected. The drop-down menu disappears as soon as the mouse moves away from the text: Click here to view the test site ...

The Bootstrap 4 accordion won't stay closed and keeps popping open when I try to close

Having an issue with the example accordion from Bootstrap 4's documentation. After troubleshooting, I discovered that the 'show' class gets removed and added again when trying to close the card. Links to images: https://i.sstatic.net/lxKiK. ...

Show a table containing dynamic information, featuring 10 rows for each column. The header should be present for each additional column that is added

I have incoming dynamic data that I need to display in columns, with 10 records in each row. Currently, I am able to display 10 rows as expected. However, I want the header to repeat each time an additional column is added. How can I achieve this using the ...

Troubleshooting issues with CSS absolute positioning

I'm having trouble getting my icons to align in the center of the screen and I can't figure out why it's not working CSS: #Main{ position: absolute; top: 50%; left: 50%; } HTML: <!DOCTYPE html> <html> <head& ...

How about placing one element above another? What sets apart using the margin property versus the position property for achieving this effect?

As I pondered the concept of stacking context, a question arose in my mind. Through my readings, I learned that by not applying any CSS properties that create a stacking context (such as position), it is possible to stack elements on top of each other usin ...

CSS Assistance - Ensuring top div remains fixed while allowing bottom div to occupy remaining page space - Troubleshooting bottom div background issue

Currently in the process of building a new website and below is the initial code draft. Encountering an issue with the bottom content div. When there is less content, the bottom div fills up the remaining browser space just fine. However, when more conte ...

Creating an HTML dynamic table with fixed height to prevent expanding when adding text

I have a dynamic table with fixed width and height. By using a random function, I determine the number of cells (ranging from 3x3 to 7x7) in the table. The table renders correctly, but when clicking on a cell to write a letter, the row expands in height. H ...

CSS - The color gray transforms into a crisp white when printed

div { background-color: #dcdcdc; } I've noticed that the gray color of the above code looks nice on screen but turns out white when I try to print it. Any suggestions on how to solve this issue? ...

Turn off jQuery for mobile devices

I need assistance in modifying a script that causes a fade effect on certain elements only on desktop and not on mobile devices. I have attempted using the code below, but it seems to hide all elements on all screen resolutions. In my CSS, I am applying ...

Tips for resolving issues with a bootstrap carousel containing several images

I have a carousel here that I'm trying to create with multiple images, similar to a Netflix carousel. <div class="container"> <div class="row"> <div class="col-sm-12"> <div id="carouselExampleCaptions" cl ...

Accordion-style elements arranged in a grid format, smoothly displacing surrounding content

I am facing an issue with a grid of accordions, as demonstrated in the codesandbox linked below. The problem arises when I open one accordion, causing all the accordions in the row below to shift down. Ideally, only the accordion directly below should be p ...

Issues with CSS transitions/animations not functioning properly across different browsers

Take a look at this FIDDLE Link. I'm facing an issue where the animation works smoothly in Firefox, but it's not functioning as expected in Chrome. Kindly open the fiddle in both browsers (Chrome and Firefox), hover over the image, and notice t ...

MySQL unable to access information entered into form

After creating a new log in / register template using CSS3 and HTML, I now have a more visually appealing form compared to the basic one I had before. To achieve this look, I referenced the following tutorial: http://www.script-tutorials.com/css 3-modal-po ...