What could be causing my animation to not complete its full rotation?

Hi there! I've been using @webkit in CSS to create animations for some shapes, and I'm trying to make them rotate fully back to their original positions around a center point. I attempted to rotate the shapes around the z-axis but encountered an issue. The script I wrote seems to work, but it results in the first shape moving to its starting position (all shapes end up transforming to different positions before returning to their original place) and then replaying the animation in a loop with only the starting position visible. How can I modify the script so that the shapes rotate fully?

#catogories-1 {
  width: 133px;
  position:fixed;
  left: 50%;
  right: 50%;
  top: 45%;
  z-index: 6;
  -webkit-animation: catogories-1 1.5s linear infinite;
}

#catogories-2 {
  width: 133px;
  position:fixed;
  left: 55%;
  right: 45%;
  top: 37%;
  z-index: 4;
  -webkit-animation: catogories-2 1.5s linear infinite;
}

#catogories-3 {
  width: 133px;
  position:fixed;
  left: 45%;
  right: 55%;
  top: 34%;
  z-index: 3;
  -webkit-animation: catogories-3 1.5s linear infinite;
}



#catogories-4 {
  width: 133px;
  position:fixed;
  left: 35%;
  right: 65%;
  top: 37%;
  z-index: 4;
  -webkit-animation: catogories-4 1.5s linear infinite...
<div class="catogories">

  <div id="catogories-1">

    <img src="images/Rectangle-... 

Answer №1

It seems like your current animation is moving the images in a linear path that resembles part of an ellipse. Are you aiming for a complete circular motion?

I once dabbled in creating a CSS ferris wheel from scratch. Although I never quite completed it, you can take a look at how the circular animation was achieved:

http://jsfiddle.net/GolezTrol/u9d8aha3/1/

The key lies in the rotation animation defined as follows:

@keyframes spin { 100% { -transform: rotate(360deg); } }

In essence, apply a rotating animation to the element. Rotating a wrapper will cause everything within it to also rotate. However, you can rotate the individual items in the opposite direction to maintain their upright position.

.wrapper {
  margin: 0 auto;
  position: relative;
  top: 50px;
  
  width: 200px;
  height: 200px;
  border: 1px solid blue;
}

.item {
  width: 20px;
  height: 20px;
  border: 1px solid red;
}

/* Both the wrapper and the item have the same animation */
.wrapper,
.item
{
  -webkit-animation:spin 20s linear infinite;
  -moz-animation:spin 20s linear infinite;
  animation:spin 20s linear infinite;
}

/* The item animation is reversed compared to the wrapper, allowing it to stay upright */
.wrapper {
  -webkit-animation-direction: reverse; /* Chrome, Safari, Opera */
  animation-direction: reverse;
}

@-moz-keyframes spin { 100% { -moz-transform: rotate(360deg); } }
@-webkit-keyframes spin { 100% { -webkit-transform: rotate(360deg); } }
@keyframes spin { 100% { -webkit-transform: rotate(360deg); transform:rotate(360deg); } }
<div class="wrapper">
  <div class="item">
    X
  </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

Display the initial page and activate the first navigation button when the page loads

Greetings to everyone. I am new to the world of jquery and currently in the process of learning. This is my script: <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"> </script> <script> $(function () { $ ...

Is there a way to align this in a horizontal inline block?

I have this element and I would like it to display inline-block but horizontally. Currently, it is displaying as inline-block but vertically. Here is my HTML: <div class="ondisplay"> <div class="left-text"> <p&g ...

Fluid animation using CSS for recently added elements in a scrolling list

I've been searching for a way to create a smooth animation effect when a new element is added to a scrolling list. For example, as a new element is added to the top of the list and older elements are pushed down, I want the transition to be visually ...

Switch the accordion to open or close

I am struggling to create an accordion menu that toggles open and close using the same button. Right now, it only opens and I cannot figure out how to make it close as well. Below is my current code, or you can view it on jsFiddle: http://jsfiddle.net/nd ...

Using JavaScript to fetch HTML and apply CSS dynamically

Is there a way to retrieve all HTML within a div along with the corresponding CSS? A majority of the CSS is defined in classes within an external stylesheet. document.getElementById("mydiv") Currently, using the above code only fetches the HTML with inli ...

Inline checkbox label with Bootstrap 5 styling

How can I align the checkbox with its label? Example <div class="row g-1 border-bottom p-3"> <div class="col border-end justify-content-center d-flex align-items-center"> <div class="h6 text-sm-center h-25&quo ...

What is the specific use of the second app.css file in Laravel?

I'm currently delving into Laravel 8, and I'm perplexed by the role of Resources\css\app.css. While every other component in the Resources directory serves a clear function, the app.css file appears to be empty. Even when I attempt to a ...

perplexed by the pair of buttons

Is it possible to change the default behavior of an ASP.NET button so that pressing the ENTER key on the keyboard submits a different button instead? If so, how can this be done? ...

Ways to conceal an element in Angular based on the truth of one of two conditions

Is there a way to hide an element in Angular if a specific condition is true? I attempted using *ngIf="productID == category.Lane || productID == category.Val", but it did not work as expected. <label>ProductID</label> <ng-select ...

Other options besides re-flowing and repainting

After doing some research on various platforms like Stack Overflow, I've come across information stating that re-paints and re-flows can be quite taxing on a browser's resources. I am interested in learning about alternative CSS/JS techniques to ...

"Position centrally on the inside, using flexbox to fill the entire

Seeking assistance with aligning the text in the center of the flexboxes so that the h4 and p elements in the large box are centered within their respective boxes, as well as ensuring the text in the two smaller boxes is also centered. Any help would be gr ...

Ways to center elements horizontally without relying on Flexbox layout?

Is there a way to arrange the web elements side by side without relying on Flexbox? Although an effective tool, Flexbox does not function properly with IE 9 or 10. I am aiming for the text inside the link to be displayed immediately next to the images. The ...

My website is currently experiencing issues with all of the CSS references not working. This problem applies to both external and internal CSS files and consistently

I'm encountering 404 errors when trying to load both internal and external files on a website through my browser. My code snippet looks like this: <link rel="stylesheet" type = "text/css" href='anoceanofsky.css'/> Despite clearing m ...

Modify the background color of a div when it contains a particular string of text

https://i.sstatic.net/Ab5S9.png Looking for assistance with a basic jQuery script that can search for a specific text string. If the text is found, I want to change the CSS of the containing div. The HTML+CSS+JS code would be like: $(".ng-cell .ngCell ...

Tips for locating an element without a class assigned

I am currently utilizing the webdriverIO framework for my script, specifically working with a calendar where I need to extract only the days from the current month. Below is an excerpt of the HTML code: <tr class="daysrow"> <td class="day w ...

Setting off an occurrence

On a specific website, there is a dropdown menu structured like this: <select class="categories-options" data-level="1" name="level1-option" id="level1-option" required=""> <option value="">default</option> <option value="p1" data ...

Utilize CodeIgniter to input information into the database

I am encountering an issue with inserting data into a database. Instead of successfully adding the data, it just displays the input on the URL bar after submitting the form. The view input_data.php can be found at: C:\wamp\www\CodeIgniter&b ...

Two divisions inside another "wrapper" division - Adjusting the width

I'm facing an issue with my CSS. I have a container div "container" that contains two other divs - "left" and "main". The width of the container is set to 90% of the body's width, with a margin of 3% auto to center it. .container{ margin:3% auto ...

Tips for Positioning Sidebar Elements Relative to Content IDs

My goal is to have sidebar elements align with specific id tags in the main content, rather than just stacking up one after another. I want the sidebar elements to align with certain id tags mentioned in the main post content. The image at shows the basic ...

How to align text to the bottom of a div using CSS

I am struggling to position the text 'About' at the bottom of an image. The red line marks the spot where I want the text aligned at the bottom. However, every method I try results in inconsistent outcomes when viewed on desktop and mobile device ...