CSS animation fails to animate the object

I am encountering an issue with a CSS animation that I am trying to implement for each child within a nav element. Specifically, I am attempting to create a dynamic stock panel.

Interestingly, when I add another CSS attribute like color, it works as expected. However, the animation itself is not functioning properly.

Does anyone have any insights or solutions to this problem?

function DoAnimation(animation, a) {
  var parent = a.parentElement
  if (animation != null) {
    parent.removeChild(a);
    parent.appendChild(a);
    console.log(1);
    a.style.animationName = animation;
    a.style.animationDuration = "2s";
  }
}
@keyframes MoveStockTORIght {
  from {
    left: 0;
  }
  to {
    transform: translateX(100px);
  }
}

.SiteNav {
  overflow: hidden;
  text-align: center;
  margin: auto;
  text-align: center;
}

.SiteNav a {
  gap: 10%;
  padding: 1%;
}
<nav class="SiteNav" id="siteNavigantion">

          &(#60);a href="StockPage.aspx?stock=MSFT" style="color: green; animation-name: MoveStockTORIght; animation-duration: 2s;" id="a0">MSFT   294.23</a>
          <a href="StockPage.aspx?stock=CLOV" style="color: green; animation-name: MoveStockTORIght; animation-duration: 2s;" id="a1">CLOV   8.06</a>
          <a href="StockPage.aspx?stock=LCID" style="color: green; animation-name: MoveStockTORIght; animation-duration: 2s;" id="a2">LCID   22.87</a>
          <a href="StockPage.aspx?stock=SAVA" style="color: green; animation-name: MoveStockTORIght; animation-duration: 2s;" id="a3">SAVA   51.08</a>
          <a href="StockPage.aspx?stock=AAL" style="color: green; animation-name: MoveStockTORIght; animation-duration: 2s;" id="a4">AAL   20.13</a>
          <a href="StockPage.aspx?stock=AMZN" style="color: green; animation-name: MoveStockTORIght; animation-duration: 2s;" id="a5">AMZN   3246.3</a>
          <a href="StockPage.aspx?stock=NFLX" style="color: green; animation-name: MoveStockTORIght; animation-duration: 2s;" id="a6">NFLX   627.04</a>
          <a href="StockPage.aspx?stock=GOOG" style="color: green; animation-name: MoveStockTORIght; animation-duration: 2s;" id="a7">GOOG   2776.95</a>
          <a href="StockPage.aspx?stock=AAPL" style="color: green; animation-name: MoveStockTORIght; animation-duration: 2s;" id="a8">AAPL   142.81</a>
          <a href="StockPage.aspx?stock=NVDA" style="color: green; animation-name: MoveStockTORIght; animation-duration: 2s;" id="a9">NVDA   206.95</a>
</nav>

Answer №1

Have you considered using Marquee for this purpose?

.SiteNav {
  overflow: hidden;
  text-align: center;
  margin: auto;
  text-align: center;
}

.SiteNav a {
  gap: 10%;
  padding: 1%;
}

marquee a { text-decoration: none; color:green; }
<marquee class="SiteNav" id="siteNavigantion">


  <a href="StockPage.aspx?stock=MSFT" id="a0">MSFT   294.23</a>
  <a href="StockPage.aspx?stock=CLOV" id="a1">CLOV   8.06</a>
  <a href="StockPage.aspx?stock=LCID" id="a2">LCID   22.87</a>
  <a href="StockPage.aspx?stock=SAVA" id="a3">SAVA   51.08</a>
  <a href="StockPage.aspx?stock=AAL"  id="a4">AAL   20.13</a>
  <a href="StockPage.aspx?stock=AMZN" id="a5">AMZN   3246.3</a>
  <a href="StockPage.aspx?stock=NFLX" id="a6">NFLX   627.04</a>
  <a href="StockPage.aspx?stock=GOOG" id="a7">GOOG   2776.95</a>
  <a href="StockPage.aspx?stock=AAPL" id="a8">AAPL   142.81</a>
  <a href="StockPage.aspx?stock=NVDA" id="a9">NVDA   206.95</a>
</marquee>

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

Using async/await in combination with Vuex and Feathers

Please review my code below. I am attempting to integrate Async Await into vuex. While everything is functioning properly, I would like to call another action after this one using async await. However, the expected result is not being achieved as the conso ...

What is the best way to transfer a JavaScript variable to a PHP file and then store it in a PHP variable?

I am working on a webpage that displays multiple images, each of which can be replaced by another image in the same location. Adjacent to each image is a form where users can upload the new image. One important requirement is that the newly uploaded image ...

Which data types in JavaScript have a built-in toString() method?

Positives: 'world'.toString() // "world" const example = {} example.toString() // "[object Object]" Negatives: true.toString() // throws TypeError false.toString() // throws TypeError Do you know of any other data types that wi ...

Is there a way to apply the css blur filter without losing the opacity of the edges?

I'm experimenting with adding a CSS blur filter to an image while keeping the opacity intact. When I test it with a simple blue square image, the edges become transparent and reveal the underlying black div. Is there a way to achieve the blur effect w ...

Unforeseen rotation happening in CSS animation

I find myself struggling with my math skills from junior high. My goal is to rotate two divs around the Y axis in opposite directions. I have set up two animations for this purpose: @-webkit-keyframes first{ 0% { -webkit-transform: rotateY(0); } ...

Retrieving data from a server using the GET method with parameters through axios in a React Native application

As someone new to Web requests, I have encountered a challenge that seems simple but has proven difficult for me. Despite searching the web, I am struggling to get a working response. When I input the URL 'http://www.test.com/callservice.php?action=s ...

How can a loading circle be displayed upon clicking a button on a PHP website using JavaScript?

As a newcomer to the world of JavaScript programming, I'm facing a challenge that seems deceptively simple. My goal is to display a loading circle when a user clicks on an upload button, trigger external PHP code for image processing, and then make th ...

Animating a spinning SVG path around its center within a larger rectangular box

Is there a way to rotate a smaller SVG path within a larger rectangle around its own center? The current code rotates the entire space. <animateTransform attributeType="xml" attributeName="transform" type="rotat ...

Creating a plug-in enables you to discover and journey through geographical information on a three-dimensional globe using a web browser

Recently, I completed a mini project utilizing the three.js library. Now, I am looking to develop a Javascript plugin that can efficiently load large 3D models and utilize a Javascript API on the client side similar to Google Earth Plugin for faster perfor ...

Reactive property cannot be defined on an undefined, null, or primitive value within the context of Bootstrap Vue modal

Can someone please assist me with this error message? It says "app.js:108639 [Vue warn]: Cannot set reactive property on undefined, null, or primitive value." I encountered this error while working with a Bootstrap Vue modal. Here is a snippet of my code: ...

The Angular Google Maps Module fails to initialize

After updating angular-google-maps to version 2.0.1 via bower and adding the required dependencies (bluebird, jquery, loadash), I noticed that my app works fine when I comment out google-maps. This suggests that the issue lies with angular-google-maps. He ...

Using an AngularJS directive to trigger a function with ng-click

Everything is working well with my directive, but I would like to utilize it within ng-click. Unfortunately, the function inside the link is not getting triggered. Here's the link to the code snippet. <div ng-app="editer" ng-controller="myCtrl" ...

Tips for redirecting JavaScript requests to the target server using curl on a server

Currently, I am running a crawler on my server and require the execution of JavaScript to access certain data on the target site that I want to crawl. I recently had a question about a different approach to this issue, but for now, I need help with the fol ...

JQuery encountered a HTTP 404 error, signaling that the server was unable to locate anything that matched the requested URI

I am currently learning front-end development on my own and encountered an issue with implementing jQuery. You can find all the files for my site here: The problem I am facing is that there should be blog posts displayed between the header and navigation ...

Trigger a change event for a Material Checkbox by referencing its unique identifier

<div *ngFor="let cus of deselectedList | keyvalue" (click)="clickCheckBox('customer_'+cus.key+'_checkbox')"> {{cus.key}} <mat-checkbox id="customer_{{cus.key}}_checkbox" (change ...

Retrieve the color of the TripsLayer in deck.gl

layers.push(new TripsLayer({ id: 'trips', data: trips, getPath: (d: Trip) => d.segments.map((p: Waypoint) => p.coordinates), getTimestamps: (d: Trip) => d.segments.map((p: Waypoint) => p.timestamp), ...

Discovering a class within a div element using Selenium

Currently, I am attempting to utilize Selenium in Python to locate and click on the 'X' button. This action will redirect me to the next page where I can extract some crucial information. However, I am encountering difficulties in finding the ele ...

Contrast the schedules of two different calendars

Attempting to compare two timetables for a college project in order to identify available time slots in one timetable and concurrently check for events happening in the other. For instance, if a student has an open period from 4-5 on a Tuesday, the code sh ...

JavaScript click event not triggering on ASP.NET button

Currently, I am attempting to invoke a C# function from JS without using ajax. One approach I have tried is creating an ASP.NET button that, when clicked, calls the C# function and triggers the click event from JS: In the HTML section: <asp:Button run ...

How can I add text to the title of a border using Bootstrap5?

I am attempting to create a design where text appears within the border of an element. I am currently utilizing Bootstrap 5 and jQuery for this project. Despite my efforts with fieldset and legend elements, I have not been successful in achieving the desir ...