What is the best way to rotate an SVG path element without it spinning in circles?

I am trying to rotate 3 paths in an SVG continuously, but I am having trouble getting them to rotate properly. The code I used worked fine with a single path SVG, but not with this one. I also have several others that I would like to rotate in a fixed position. Check out the source code and preview here!

  .rotate {
  animation: rotation 8s infinite linear;
}

@keyframes rotation {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(359deg);
  }
}

Answer №1

Changing the rotation pivot point is essential for rotating an item around its center rather than the default upper left corner.

.rotate {
    transform-origin: 50% 50%;
    animation: rotation 8s infinite linear;
}

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

Tips for customizing the appearance of various classes in Bootstrap 4

I am struggling to personalize the Bootstrap switch due to the middle toggler limitation. For customization purposes, I aim to increase the width and height of the switch to ensure visibility across various resolutions. My approach involves utilizing clas ...

Tips for creating a div element that closes on the second click:

On the PC version, I have three blocks that open and close perfectly when clicked. However, on the mobile version, when I click on one block, it opens but does not close unless I click on another block. Additionally, if I click again on the same block th ...

Ensuring the bottom border of an element extends to the edge of the screen when utilizing a 960 grid in HTML/CSS

I am currently working on creating a website layout using the 960 grid system developed by Nathansmith. I am facing an issue in extending the bottom border of an element to reach till the end of the screen while keeping the element inside a container div. ...

The comparison between dynamically adding elements through Javascript and hiding them using CSS

I am contemplating the advantages and disadvantages of adding elements to a page and setting display:none versus creating a function that dynamically generates the elements and appends them where needed. In my current situation, I am implementing a reply ...

Click anywhere outside the sidemenu to close it

I want the menu to behave like the side menu on Medium. When the side menu is open and the user clicks outside of #sidebar-wrapper, the side menu should close. Currently, I have to click the toggle X to close the menu. html <a id="menu-toggle" href="# ...

Utilize React's Bootstrap NavBar Container and automatically adjust its width

I am struggling with implementing a NavBar from react bootstrap. There seems to be a <div class="container"> that is causing the width to be fixed. How can I adjust this width to be set as auto? https://i.sstatic.net/g1uSG.png I have attempted the ...

Beside the element, a dropdown navigation menu emerges

Trying to work on a dropdown menu here. It appears to be functioning, but there's a small issue - the dropdown shows up on the right side of the element instead of directly below it. I have a feeling it has to do with either position or padding, but I ...

Even when set to 100% height, my div only extends halfway down the page

I'm having an issue with the page here. The div .menu-content is only reaching half the page, even when set to 100% height. I can't figure out why this is happening. Any help would be appreciated! <div class = "menu-content"> <div clas ...

What causes my words to link together, and what is the term for this phenomenon?

Is there a specific term for the way my font is changing automatically? How can I emulate this effect on other text? And how do I remove it if needed? https://i.sstatic.net/yIe2f.png ...

Animation does not trigger before switching pages

I'm attempting to create an animation that occurs before the page transitions. After finding a jQuery script on this site and tweaking it to match my HTML, I realized the code works in a fiddle but not on my actual page. Any assistance would be greatl ...

Utilize CSS selector to modify the class of every second pair of div elements

I attempted to utilize CSS to target a group of divs in pairs of 2 with an interval of 2. For example: I have AA AA AA AA AA AA but I need to apply different styles to every 2 elements (where A and B represent DIVs): AA BB AA BB AA BB I have tried the ...

Ways to display JSX with formatted new lines and spaces in React.js?

Here is an image displaying a comparison between my console log and React website in Google Chrome. Check out the Console log and Chrome website Notice how the console output is neatly formatted with new lines and indents, while the text below "Generated ...

Mobile view not displaying navbar menus

My website is responsive and functions properly on desktop, but I'm encountering issues with the menus in the navbar not displaying correctly on mobile and tablet views. To see a screenshot of the problem, you can click on this link: You can visit m ...

Guide to creating an autoplay feature for a CSS slider

I have created a basic HTML/CSS slider with just 2 slides and I'm looking to set it to automatically switch slides every 7 seconds. Since I'm not well-versed in jQuery or JavaScript, I'm hoping for a CSS-based solution... Could you assist m ...

Adaptable navigation options

So, I've been facing a challenge with my Bootstrap 4 navigation bar. The nav-items are going right across the navbar but I want the spacing between each nav item to adjust based on the viewport size to prevent any items from falling outside of view. I ...

Space within a receptacle

As a newcomer to bootstrap5, I am encountering whitespace issues on the left side of my screen. While everything looks fine in full-screen mode, the whitespace around the image persists when I test responsiveness. https://i.sstatic.net/gZTq5.jpg Despite t ...

Flexbox sets aside space for resized svg images

I am currently working on my site header and I want to implement flexbox for this purpose. I tried using justify-content: space-between; to evenly distribute the empty space between the divs. However, when I add an SVG image and scale it down to fit the ...

Distinguishing background colors depending on the browser's compatibility with CSS properties

I've successfully designed a polka dot background using pure CSS: .polka-gr{ background-image: radial-gradient(#FAFFB3 20%, transparent 0), radial-gradient(#F1C3CB 20%, transparent 0); background-size: 30px 30px; background-positio ...

Alignment of headline remains off-center despite having the text-center attribute

I'm currently developing a school project website and I'm facing an issue with centering my headlines. Specifically, I can't seem to figure out how to center my h1. Everything else is working fine except for that particular headline. I&apo ...

Tips for concealing the check mark within a checkbox upon selection

I have checkboxes arranged in a table with 23 columns and 7 rows. My goal is to style the checkboxes in a way that hides the check mark when selected. I also want to change the background image of the checkbox to fill it with color when marked. Can someone ...