Moving items in a leftward direction


I am trying to create a CSS animation that makes multiple objects slide from right to left. The height of these objects should be random and the speed of the animation should also vary randomly. While I have successfully achieved this using JavaScript, I am facing an issue where the objects seem to randomly "refresh" or jump around the page. Despite trying several methods to troubleshoot, I have been unable to pinpoint the root cause of this problem.
My goal is to replicate the background animation seen on the following website:

Below is the code snippet I am currently working with:

Thanks

Edit:
I should note that this code only functions properly in Chrome for now.

"use strict";

/*jslint devel: true */
// JavaScript code here
:root {
  /* CSS variables definitions */
}

div.box1 {
  /* Styles for box 1 */
}

/* Keyframes animations for each box */

@keyframes example1 {
  /* Animation keyframes for box 1 */
}

/* Repeat the above @keyframes block for all boxes (example2, example3, etc.) */
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>CSS Animation Test</title>
  <script type="text/javascript" src="java.js"></script>
</head>


<body>
  <!-- HTML structure for displaying animated boxes -->
  <div id="boxref1">
    <div class="box1">Box 1</div>
  </div>

  <!-- Repeat the above div structure for other boxes (box2, box3, etc.) -->

</body>

</html>

Answer №1

I don't see any issue that you're referring to. It might be due to a performance bottleneck caused by animating the left property.

It's recommended to use the left and top properties only for randomizing the initial position of your boxes, and then utilize

transform: translateX(-150px)

instead of using

left: -150px

to move them to the left.

Changing the left or top properties during animation can lead to multiple browser repaints. You can verify this yourself by enabling the "paint flashing" flag in the Rendering tab of Chrome Developer Tools.

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

How DataTables Handles Loading and Rendering Time Delay

Utilizing DataTables in conjunction with Bootstrap 4 for client-side processing while displaying approximately 2,000 records. The loading time is acceptable, but upon refreshing the page (F5), I observe an unformatted DataTable briefly appearing. It seems ...

Content towering over the footer

Can anyone help me figure out how to create a footer that appears behind the content when you scroll towards the end of a website? I've tried looking for tutorials online, but haven't found exactly what I'm looking for. Most of what I'v ...

Add a new key-value pair to the mock data by clicking on it

Hey there! I'm currently tackling a task that involves toggling the value of a boolean and then appending a new key-value pair on click. I've been attempting to use the . operator to add the new key-value pair, but it keeps throwing an error. In ...

Unable to render Blender model in threeJS scene due to undefined condition

I've tried following solutions from Stack Overflow to resolve this issue, but I'm still unable to load external objects (Blender). Essentially, I exported it as a ThreeJS JSON file, here is the content of my JSON file: { "textures":[], ...

Is it necessary to execute 26 individual mysql queries in order to group items alphabetically in a directory listing page?

I am looking to create a directory listing page for my website that displays all of my articles grouped by the first letter of their titles. Do I have to execute 26 MySQL queries like: mysql query like "SELECT * FROM articles Where title like 'a%&ap ...

Displaying a hand cursor on a bar chart when hovered over in c3.js

When using pie charts in c3js, a hand cursor (pointer) is displayed by default when hovering over a pie slice. I am looking to achieve the same behavior for each bar in a bar chart. How can this be done? I attempted the CSS below, but it resulted in the h ...

Angular displaying undefined for service

I have created a service for uploading images to a server, and I am encountering an issue when calling this service from my controller. The error message indicates that the function 'uploadFileToUrl' is undefined. Below is the code for my servic ...

Utilizing a custom font to emphasize the extended phrase in the following sentence

I've been trying to use word-wrap to break long words into the next line, but unfortunately it's not working as expected. You can view my JsFiddle code for reference. The divs on my page are generated dynamically, and here is an overview of what ...

How to stop an AngularJS controller from running when the element is hidden

I came across this code snippet .state('fooState', { url: '/foo', templateUrl: 'path/to/bar.html', controller:'parentController' }) // Here's the content of bar.html <div class="sample"> ...

IE9 is not recognizing CSS styles

Why are my CSS styles not working in IE 9 but they work in IE 8 and Chrome? In the code snippet below, the style cpHeader is defined in a separate CSS file. Any ideas on why IE 9 is failing to render the styles properly? <asp:Content ID="Content2" Cont ...

Using custom fonts in HTML on Bootstrap is causing issues

After struggling with a persistent problem for quite some time, I decided to delete my initial question since I was already utilizing Bootstrap. However, I am facing an issue where my custom fonts are not being loaded even though my main.css and bootstrap. ...

unable to retrieve the response from a POST request sent to a node server

Currently in the process of learning how to utilize node and express, I have embarked on creating a sample website that incorporates both along with the Google translate API. The goal is to explore the numerous features offered by these technologies. Unfor ...

What is the process of setting up various initialization parameters for a DataTable?

Here is a snippet of JavaScript code I have been using to initialize a DataTable: $(document).ready(function() { $('#example').DataTable( { dom: 'Bfrtip', buttons: [ 'copyHtml5', &a ...

Adapt vanilla JavaScript code to be compatible with Node.js, MongoDB, and Express framework

In the midst of working on a blog project for my class, I find myself faced with the challenge of integrating Nodejs, Mongo, and Express into our existing setup. Up until now, we have been gradually transitioning to using Express in our application develop ...

Populating a text area using HTML and displaying &lt; instead of <

I developed a small editor for managing resource files. Within this editor, I display the content of a specific resource item in a textarea: <textarea cols="85" rows="12" id='EditItemTextArea'><%# Eval("Translation")%></textarea& ...

The issue of Vuetify table failing to scroll in IE11

Having trouble getting Vuetify to function in my Vue project on IE11. I need to make content responsive when it's not available, or add a horizontal scroll bar in IE11 when the content is too wide. [Visit this Codepen for reference][1] [1]: https ...

What steps are needed to set up React SPA authentication using Keycloak and the PKCE flow?

This is my first time diving into the world of Keycloak. I have successfully set up a Keycloak instance on my local machine where I can create realms, clients, and more. I've come across several examples of using React with Keycloak, but none of them ...

Mapping an array of objects using dynamically generated column names

If I have an array of objects containing country, state, city data, how can I utilize the .map method to retrieve unique countries, states, or cities based on specific criteria? How would I create a method that accepts a column name and maps it to return ...

Template not rendering array data correctly in Meteor

Here is an example of the array structure: var myarray = [ device1: [ name:device1 , variables: [ variable1: [ name: variable1, unit: "a unit", ...

Ways to store debug logs in a file within my project

In the project I am currently working on, I incorporate the Debug package which can be found at https://www.npmjs.com/package/debug. As part of this setup, I have set an environment variable (variable name: DEBUG & value:*). As a result, I am able to vie ...