I'm keen on creating a marquee animation using Tailwind and Next.js

I'm working on creating a marquee animation using Tailwind CSS and Next.js, and I've made some progress. However, the issue I'm facing is that the items are not displaying one after the other smoothly; there seems to be a delay when the second item appears.

What I want it to look like: https://i.stack.imgur.com/5AKUJ.png but currently, it looks like this https://i.stack.imgur.com/x48lE.png.

Below is the Tailwind CSS code:

.animate-marquee {
    animation: marquee 10s linear infinite;
    float: left;
}

Here is the component code:

import { useRouter } from "next/router";
import pathChecking from "../../utils/pathChecking";
import Image from "next/image";

const testimonial_data = [
{
desc: "Inform, inspire, connect, and collaborate for meaningful action.",
id: "0General Partner at Entrepreneur",
},
{
desc: "Addressing the world’s biggest environmental and social challenges.",
id: "1General Partner at Entrepreneur",
},
{
desc: "Fun, interactive, and immersive technology for real-world positive outcomes. ",
id: "2General Partner at Entrepreneur",
},
];

const HeroSliderComponent = () => {
const route = useRouter();

return (
<>
<div className=" flex animate-marquee space-x-8 w-10000">
{testimonial_data.map((item, index) => {
const { id, img, title, desc, name } = item;
return (
<div className="text-white" key={id}>
<div
className={`relative rounded-2.5xl border border-jacarta-100 bg-white p-12 transition-shadow hover:shadow-xl dark:border-jacarta-700 dark:bg-jacarta-700 `}
>
<p className="block font-display text-xl font-medium group-hover:text-accent dark:text-white text-center">
{desc}
</p>
</div>
</div>
);
})}
</div>
</>
);
};

export default HeroSliderComponent;

I'm aiming for an infinite marquee with smooth transitions between items.

Answer №1

Feel free to test out the code snippet below:

import { useRouter } from "next/router";
import pathChecking from "../../utils/pathChecking";
import Image from "next/image";

const testimonial_data = [
  {
    desc: "Empower, engage, and create impact through collaboration.",
    id: "0General Partner at Entrepreneur",
  },
  {
    desc: "Solving the world’s most pressing environmental and social issues.",
    id: "1General Partner at Entrepreneur",
  },
  {
    desc: "Innovative technology for positive real-world results with a touch of fun.",
    id: "2General Partner at Entrepreneur",
  },
];

const HeroSliderComponent = () => {
  const route = useRouter();

  return (
    <div className="flex overflow-hidden">
      {[1, 2].map((num) => {
        return (
          <div
            key={num}
            className="min-w-full flex animate-marquee space-x-8 w-10000"
          >
            {testimonial_data.map((item, index) => {
              const { id, img, title, desc, name } = item;
              return (
                <div className="text-white" key={id}>
                  <div
                    className={`relative rounded-2.5xl border border-jacarta-100 bg-white p-12 transition-shadow hover:shadow-xl dark:border-jacarta-700 dark:bg-jacarta-700 `}
                  >
                    <p className="block font-display text-xl font-medium group-hover:text-accent dark:text-white text-center">
                      {desc}
                    </p>
                  </div>
                </div>
              );
            })}
          </div>
        );
      })}
    </div>
  );
};

export default HeroSliderComponent;

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

Configuring webpack in Next.js can be done through the `next.config.js` file

I am currently utilizing NextJS and incorporating the react-data-export plugin for generating xls files. The description of the plugin mentions: This particular library makes use of file-saver and xlsx, and by integrating json-loader, the desired functio ...

PHP code for displaying images on the same level

Is there a way to position images side by side in PHP? For example: image image image image. Currently, with the following code: print "</h2><br><a href='form.php'><img src=***.jpg width=100 height=100 /><br> ...

Aligning Text Vertically with an Image in ul/li List Items

Apologies if this question has already been asked, but I've checked several similar inquiries in an attempt to merge the solution without much luck. I currently have a bootstrap row with two col-md-6's. The first column contains an image, while t ...

What are some methods for applying border styles to the first and last row of a table using Material UI?

In my current project, I am utilizing the combination of Material UI and React Table. Recently, I was asked to implement an expandable row feature, which I successfully added. Once the user expands the row, we need to display additional table rows based on ...

A more efficient approach to creating a personalized design

After realizing the original question was unclear and wouldn't solve my problem, I have decided to edit it and create a new one. For my project, I require a customized layout where users can move, resize, add, or remove each box according to their pr ...

Using jQuery to retrieve child elements and assign numerical values to them

Looking for a jQuery function that can apply different CSS attributes to children elements of a div. <div class="container"> <div class="autogenerated-div"></div> <div class="autogenerated-div"></div> <div class="aut ...

Connecting a segment on a different page in Next.js

Is it feasible to create a link that directs to a specific section on another page in Next.js? When clicking the link, I would like to be taken directly to the designated section. While this is achievable in standard HTML, can it also be implemented in N ...

Set the first link in a menu to be highlighted as active using jquery

In order to mark the first link in my menu as active, I need it to have specific CSS settings applied. Using jQuery to add these settings to every link when clicked on makes it a bit tricky (simple menu = clicking changes color). So, I want the first link ...

Next.js encountered an error of type TypeError when trying to iterate over a variable named "

I'm encountering a frustrating issue with my Next 13 App directory. Every time I try to run npm run build, I face an error that prevents me from deploying successfully until it's resolved. However, I am completely puzzled by what could be causing ...

Footer alignment issue when using react-full-page is causing it to not lineup at the bottom of the page

Currently, I have integrated the react-full-page package into my project. However, after adding the Footer to the routes, I noticed that the footer is only visible in the second section of the page and does not appear at the bottom as expected. If you wan ...

Tips for creating animations with JavaScript on a webpage

I created a navigation bar for practice and attempted to show or hide its content only when its title is clicked. I successfully toggled a hidden class on and off, but I also wanted it to transition and slide down instead of just appearing suddenly. Unfort ...

CSS background image not displaying in ReactJS with SCSS

Currently, I am working on a React project and I am trying to incorporate a local image from a public folder as the background for a div container with transparent color. However, I am facing an issue where the image is not being displayed. I have success ...

Unable to show the table row color using Angular in Internet Explorer

I've customized a table by changing the row color based on a property value, and I'm using ng-repeat to display the rows. Here's my table: <table class="tab table span6 tabhover" style="margin:0;" > <thead> ...

Unique text: "Personalized button design without using SVG

I've been experimenting with creating a button using SVG, but unfortunately, it seems that SVG is not supported on Next.js & Material UI. Below you'll find the code snippet and screenshot I have been working with. Any help or guidance would be g ...

Modify top position without affecting bottom alignment using CSS

I am currently working on a website that is designed to mimic a printable document. The layout consists of a header, body, and footer, with each element utilizing CSS for margin and height adjustments. The challenge lies in ensuring that the footer is alw ...

Preventing the image from being displayed when it cannot fully show is achieved through blocking the background repeat

Is there a way in CSS to only display a background image if it can be fully shown without setting the width in pixels? I want to avoid showing partial background images. Is there a CSS property that can help with this? [] <div align="left" style="pad ...

Ways to configure my react frontend to communicate with my nextjs backend

My current setup consists of a React frontend running on localhost:3001 and a Next.js backend running on localhost:3000. I have a REST endpoint at /api/employee, and I'm attempting to fetch data from my frontend using the following code: fetch(process ...

What is the best way to eliminate the blue-box-fill when buttons are clicked?

Check out this screen recorded gif on my device showcasing the blue-box-fill I'm referring to: https://i.stack.imgur.com/ajr2y.gif I attempted the following solution: * { user-select: none; -webkit-user-select: none; /* Safari */ -khtml-user-s ...

Can you explain the distinction between using fallback: false, fallback: true, and blocking in combination with getStaticPaths with and without revalidate in Next.js SSR/ISR

With the release of Next.js 10, the getStaticPaths function now requires the inclusion of the critical fallback key in its returned object, as outlined in the documentation available at: https://nextjs.org/docs/basic-features/data-fetching#the-fallback-key ...

"Challenges in styling a table within a div: the text fails to adhere to the

I am struggling to identify the source of a problem in my code. The issue seems to be related to the padding within the parent div, specifically with the text "1 Healthy Midday Meal for One Child Overseas" and how it is ignoring the 5px right padding. Upon ...