Animating a path of an SVG ellipse using CSS translate for movement

I'm a beginner when it comes to SVG animation and I've been experimenting with animating an ellipse path in an SVG using the CSS translate function as detailed on CSS Tricks.

Below is the SVG code for the ellipse itself:

<ellipse id="halo"  class="halo_path" transform="rotate(-71.04 448.99 166.502)" cx="449" cy="166.5" rx="63" ry="234.3" />

My goal is to make it move up a few pixels and then come back down in a loop, but when I applied the CSS for the @keyframe animation:

.halo_path {
    transform: rotate(109deg);
    fill: none;
    stroke: #D9CC29;
    stroke-width: 25.0519;
    stroke-miterlimit: 10;
    transform-origin: center;
    animation: move_halo 2s infinite;
    animation-direction: alternate-reverse;
}

@keyframes move_halo {
    0% {
        transform: translate(0, 5px);
    }
    100% {
        transform: translate(0, -10px);
    }
}

...the animation works, but the ellipse path appears straight instead of curved like this:

I would really appreciate it if I could achieve the up-and-down animation while maintaining the original angle of the ellipse design, which was like this:

PS - I am aiming to accomplish this without the use of JS or jQuery.

Answer №1

Transfer the animation to a higher-level element to avoid disrupting the transform of the ellipse.

html, body, svg {
  width: 100%;
  height: 100%;
}

ellipse {
    transform: rotate(109deg);
    fill: none;
    stroke: #D9CC29;
    stroke-width: 25.0519;
    stroke-miterlimit: 10;
    transform-origin: center;
}

.halo_path {
    animation: move_halo 2s infinite;
    animation-direction: alternate-reverse;
}

@keyframes move_halo {
    0% {
        transform: translate(0, 5px);
    }
    100% {
        transform: translate(0, -10px);
    }
}
<svg viewBox="0 0 1000 400">
    <g class="halo_path" >
    <ellipse cx="449" cy="166.5" rx="63" ry="234.3" />
    </g>
</svg>

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

The Django URL redirection issue is causing some trouble

I'm having trouble navigating to the next page using buttons like this: <a href="weekly/" class="btn">Weekly Report</a> <a href="daily/" class="btn">Daily Report</a> Whenever I click on the header or another button while on t ...

Decreasing the vertical size of the page

My mobile page was meant to be all black, but it's only half black now. I tried the following CSS: @media (max-width: 768px) {body, html.page-id- 28{background-color: black! important;}} @media (max-width: 768px) {. parallax-window {background ...

Icon for sorting table columns depending on the browser

Once again, I'm facing a css problem with IE8 that is leaving me puzzled. I have a sortable table that is functioning perfectly fine. Within this table, there is a direction icon that serves as a background for the header column that is sorted, changi ...

Choosing several checkboxes and populating an array with values - HTML and JavaScript

I am working on a modal dialog that displays a table with checkboxes next to user names. My goal is to link these checkboxes to the respective names so that when a box is checked next to 'Jon' in the table, the name 'Jon' gets selected. ...

Expanding and shrinking div elements in Angular with sliding effects on other divs

Hello, I am just starting with angular and angular animations, and I have encountered a problem. Here is the html code that I am working with: <div class="main"> <div class="left" *ngIf="showLeftSide" [@slideInOutLeft]></div> <di ...

Unexpected rendering occurs when using a CSS double transition

In my React application, I am working on implementing smooth page transitions for a more visually appealing user experience. While using simple fade-in/fade-out transitions, I have noticed that transitions between pages with similar content are not as smoo ...

Transform content div into a clickable element by incorporating nested divs

Here is my current layout: <div id="content"> <div id="img"><img src=""></div> <div id="main">Some content</div> <div id="btn" class="hidden"><button>Submit</div> <div class="hidden">Some ...

Steps for modifying the documents on an osCmax website

I had a developer set up my website in osCmax a while ago, and now I want to update the design of some pages using HTML and CSS on my own. While I am comfortable with HTML and CSS, I have very limited knowledge of PHP. This is my first attempt at working o ...

Tips for concealing the fourth child element within a list item

I'm facing an issue with a list of items rendered in my react component where I need to hide the 4th child of the list item. Here is the relevant html code: <div class="ExpandableContent-Content MyAccountTabList-ExpandableContentContent&qu ...

What is the functionality behind this unique SCSS mixin that combines flexbox and grid layouts?

Discover a SCSS mixin for creating flexbox/grid layouts HERE. Take a look at the complete mixin code below: @mixin grid-col( $col: null, $grid-columns: 12, $col-offset: null, $gutter: null, $condensed: false, ...

Why should you use DIV comment tags in HTML code and how can you automate their implementation?

As I've been browsing through the codes of various professional websites, I couldn't help but notice how the HTML code is often neatly commented like this: <!-- END DIV Main Menu --> This type of commenting can be really beneficial, don&a ...

Pause jQuery at the conclusion and head back to the beginning

As a beginner in the world of jQuery, I am eager to create a slider for my website. My goal is to design a slideshow that can loop infinitely with simplicity. Should I manually count the number of <li> elements or images, calculate their width, and ...

Bootstrap 3 Full-Width Responsive Image Overlapping

I have designed a grid layout with col-md-7 on the left side and col-md-5 on the right side. The images in the col-md-5 are responsive and have a full-width of col-md-12. <div class="container"> <div class="row"> <div class="col ...

Revolving mechanism within React.js

I am currently developing a lottery application using React.js that features a spinning wheel in SVG format. Users can spin the wheel and it smoothly stops at a random position generated by my application. https://i.stack.imgur.com/I7oFb.png To use the w ...

Tips for fixing footer accordion overlap issues

Just starting out with jQuery and using the Accordion feature. Noticed that when I click on the accordion, it overlaps with the footer. How can I prevent this from happening? Here is the code for the footer - <footer> <div class="row footer_ ...

Enhance Your jQuery Skills: Dynamically Apply Classes Based on URL Like a Pro!

Here is an example of HTML code for a progress meter: <div class="col-md-3" style="margin-left: -20px;"> <div class="progress-pos active" id="progess-1"> <div class="progress-pos-inner"> Login </div> </di ...

Creating a script to open multiple URLs in HTML and JavaScript

Currently, I am working on creating a multiple URL opener using HTML and JavaScript. However, I have encountered an issue where HTTP links are opening fine but HTTPS links are not. Can someone provide assistance with this problem? Below is the code snippet ...

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 ...

Troubleshooting puppeteer PDF: Unable to set table height using CSS for tr:last-child { height: 100%; }

My Node.js code snippet is as follows: await page.setContent(html, {waitUntil: 'networkidle2'}); const pdf = await page.pdf({ format: 'A4', printBackground: true, margin: { top: '14mm', // default is 0, units: mm, c ...

Altering the innerHTML of a <p> tag with a smooth transition

I am a beginner in the world of web design. I am currently working on a project where I need to continuously change the text inside a <p> element with a transition effect similar to a slideshow. Below is the code I have so far: <p id="qu">S ...