Spinning Ferris Wheel Illusion

Currently, I am working on a CSS ferris wheel animation concept. Everything seems to be in order visually, but upon closer inspection, some of the "steps" appear higher than others when at the highest point (12 o'clock position - referred to as "step1" in the code). It seems like there might be an issue with my calculations, but I'm having trouble pinpointing the exact problem.

If you'd like to take a look, here is the fiddle link: http://jsfiddle.net/Lc4qu/

HTML

<div id="wheel" style="height:600px;width:600px;margin:0;postion:relative;">
    <div class="wheel a fa">step1</div>
    <div class="wheel b fa">step2</div>
    <div class="wheel c fa">step3</div>
    <div class="wheel d fa">step4</div>
    <div class="wheel e fa">step5</div>
    <div class="wheel f fa">step6</div>
    <div class="wheel g fa">step7</div>
    <div class="wheel h fa">step8</div>
    <div class="wheel i fa">step9</div>
    <div class="wheel j fa">step10</div>
    <div class="wheel k fa">step11</div>
    <div class="wheel l fa">step12</div>
</div>

CSS

#wheel
{
    font-size: 120%;

}

div .a
{
     left:300px;
     top: 0px; 
     position:absolute; 
}
div .b
{

     left:450px;
     top:60px; 
     position:absolute; 
}
...
.fa{float:left;width}

JQUERY

    var rotation = 0
setInterval(function() {
    $('#wheel').css({
        "-moz-transform": "rotate(-" + rotation + "deg)",
        "-webkit-transform": "rotate(-" + rotation + "deg)",
        "-o-transform": "rotate(-" + rotation + "deg)",
        "-ms-transform": "rotate(-" + rotation + "deg)"
    }); 

        $('.fa').css({
        "-moz-transform": "rotate(" + rotation + "deg)",
        "-webkit-transform": "rotate(" + rotation + "deg)",
        "-o-transform": "rotate(" + rotation + "deg)",
        "-ms-transform": "rotate(" + rotation + "deg)",
    }); 

 rotation = (rotation + 1) % 361
}, 50)

I appreciate any insights or help you can offer!

Answer №1

Your step elements are currently rotated around their center, but positioned based on the top-left corner (view example)

To fix this issue, ensure that the rotation origin is set to the same point as the positioning origin (top-left corner)

Update the transform origin for the .fa elements to:

transform-origin: top left;

Include vendor prefixes for compatibility:

-webkit-transform-origin: top left;
-moz-transform-origin: top left;
-ms-transform-origin: top left;
-o-transform-origin: top left;
transform-origin: top left;

See the demo at http://jsfiddle.net/gaby/Lc4qu/7/


Additionally, you can achieve the same effect using CSS3 animations and keyframes

Add the following for .fa elements:

animation: cycle 18s linear infinite;

For the outer #wheel, include:

animation: cycle 18s linear infinite reverse;

Define the cycle keyframes for smooth animation:

@keyframes cycle{
   0% { 
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

Check out the demonstration at http://jsfiddle.net/gaby/Lc4qu/8/

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

Configuration of Bootstrap "col" without an xl number

Hello everyone, I am currently working on a project using Bootstrap, where I have a row with five child elements: <div class="container"> <div class="row"> <div class="col">[content]</div> ...

Timer counting down displayed in individual rows of a datatable

How can I implement a countdown timer for each row in a datatable using js, html, and jquery? Currently, I have successfully created a countdown timer but am unsure how to assign this timer to all rows of the datatable. In my code below, you can see that ...

Challenges encountered with relative links in the layout of a static website generator resembling padrino, sinatra, or rails, involving HTML, CSS, and haml

I'm currently utilizing a static site generator to create a website that resides on a shared network folder within my workplace. This site serves as a simple tutorial platform for my colleagues; it's not hosted on a server and remains completely ...

Secure HTML / CSS for JavaScript? I am unable to modify certain attributes during runtime

Due to ongoing discussions about blog colors for business purposes, we are looking to provide users with a "tool" (for those who are tech-savvy) to experiment with colors themselves. Our blog is a basic Wordpress site with various plugins (such as Google ...

What is the best way to display a component with multiple pieces of content?

I have a tool that generates card components, extracting data from a const array and displaying it in a table format within a card UI component. I am looking to add an ADD button inside each card to open a modal with input fields. However, the issue is tha ...

Comment block for an AngularJS function in Doxygen

For my project, I am utilizing angularJS along with doxygen. Within my angular controller, I have defined some functions in the following manner: function MyCtrl($scope) { /** * @param page String Page name * @ingroup API * @autho ...

"Troubleshoot: Issue with React's useState hook not correctly updating state within an

I'm running into an issue with updating state using the useState hook in a React functional component. The problem arises when I have an async function (getPalettesPosition) that fetches data based on the current state (paletteFilters). Despite confir ...

Tips for aligning an image of varying dimensions in the center

Although I've done some research and attempted to splice together code from various sources, including here, here, and other places, I'm still struggling with centering an image on a webpage. The page in question features three layered .png imag ...

Displaying limited items based on conditions in CSS

If there are 10 <p> tags, is it possible to limit them to only 5 by hiding the other 5 using CSS? Do I need to add a class five times with nth-child? Can CSS accommodate conditions for this purpose? Considering that the number of <p> tags is ...

Angular custom window injection

Currently, I am working on an Angular application that is housed within an Android WebView. To facilitate communication with my Android application, I have made an object accessible at the window level: window.MyAndroidApp This object contains various me ...

Initiate the AJAX call when the page is loaded

I want the AJAX request to load automatically when the page loads. Currently, I have to refresh the page for it to be loaded. Here is the updated code snippet: $(document).on("pageinit", "#members", function() { $.ajax({ url: 'data.php', succe ...

Creating padding for a Drawer component in Material-UI with React JS

I'm struggling to set a marginTop for my Drawer within the Drawer class component. Here's the code I've been working with: const theme = createMuiTheme({ root: { marginTop: '40px' }, }) class PageMenu extends React ...

Navigating through the elements of the DOM

Here is a function that deletes people from a list when you click on a certain part of the form: function ParticipantsDeleteClick(model, url) { for (i in model.Participants) { $("#delete" + i).click(function () { $.ajax({ url: url, ...

Transform a JSON array into a JavaScript array

var jsonData = JSON.parse(pump_array); var name_array = []; var data_array = []; for(var i=0;i<jsonData.pumps.length;i++) { data_array.push(data_array, pump_array.pumps[i].volume); name_array.push(name_array, pump_array.pumps[i].iName);} This snippet r ...

Issue with converting form data to JSON format

Having an issue converting a filled form in HTML to a JSON request for sending to the server via HTTP POST. Despite having a filled form, the JSON request only shows an empty array. Here is the JavaScript snippet: $("#submitSurveyBtn").on("click", functi ...

Using jQuery to verify a CSS property of an element upon window resizing

Is it possible to include a window resize function in this code? jQuery(document).ready(function($){ var $MyDiv1 = $('#mydiv1'); if ($MyDiv1.length && $MyDiv1.css('position') == 'fixed') { ...

Are you experiencing difficulties with coding text emails?

I am currently in the process of sending an email with an attached PDF file. Here is the code snippet I am using: $mpdf->WriteHTML($html); $content = $mpdf->Output('', 'S'); $content = chunk_split(base64_encode($content)); $ ...

JQuery Elements are affected by Update Panel

My Jquery code on the page is working well after a button click. However, when an update panel updates, the classes added with jquery are removed and #block-1 becomes visible. <script> $("body").on("click", "#app-nav-dash-2", function() { ...

Arrangement of visual content

As a newcomer to this, I have what may appear to be a straightforward question. I've embarked on designing my own webpage, and the code snippet below represents my progress so far. The current layout is as follows... top left - my logo top right - ...

Identify any missing periods and combine the years into a single range

I am working on restructuring year ranges with gaps and consolidating them. For example, converting [{start: 2002, end: 2020}, {start: 2020, end: null}] to {start: 2002, end: null} or [{2002, 2004},{2006, 2008}, {2008, null}] to [{2002-2004}, {2006-null}]. ...