"Utilize the hover functionality in React JS to track the mouse movement

I'm currently facing an issue with a design that involves a 6-column grid and text placed in front of it. The requirement is that when I hover over the text, the background of the corresponding grid column should change to an image. While this functionality works well, I am struggling with hovering behind the text, which seems impossible. Is there any solution available for this? Thank you!

const [disappear, setDisappear] = useState([20]);
  return (
    <PageLayout
      className="bg-softBlack"
    >
      <div className="relative h-[480px]">
        <h1
          className="absolute top-32 uppercase bg-transparent text-gray-10 text-[9.028vw] leading-[0.9] tracking-[-0.06em]"
          style={{ zIndex: 1000, mixBlendMode: "difference" }}
        >
          welcome <br />
          to the LAB.
        </h1>
        <div className="w-full h-full absolute left-0 top-0 grid grid-cols-6">
          {array.map((element, index) => (
            <div
              key={index}
              className="bg-black relative"
              onMouseEnter={() => setDisappear((prev) => [...prev, index])}
            >
              {disappear.some((el) => el === index) && (
                <Image src={element} alt="background" layout="fill" />
              )}
            </div>
          ))}
        </div>
      </div>
    </PageLayout>

Currently utilizing next js for this project, thank you.

Answer №1

Not entirely sure I understand your question, but it appears you are working with tailwindcss.

You might want to explore the group feature in the tailwind documentation for more insights.

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 offspring elements are positioned outside of the main footer element

There seems to be an issue with my <footer>. All child elements of the <footer> are appearing outside of it. Does anyone know how I can properly place child elements inside the <footer> and align them from left to right? footer{ bac ...

Error retrieving data: The JSON response was invalid, as an unexpected token `<` was found at the beginning of the response. This issue occurred while using

Utilizing the getStaticProps and getStaticPaths functions, I made a fetch API call to an API endpoint (specifically a Wordpress headless CMS) in order to set dynamic routing paths. While running npm dev, everything functions correctly as the data is succes ...

How to assign attributes to all child elements in Angular?

I have a unique component in Angular that I utilize throughout my app. It's a button component which I use by calling <app-delete-btn></app-delete-btn> wherever needed. I tried to set the tabindex="1" attribute for my component ...

Tips for personalizing and adjusting the color scheme of a menu in ant design

I am currently working on a website using reactJs and ant design. However, I have encountered an issue with changing the color of a menu item when it is selected or hovered over. Here's the current menu: Menu Image I would like to change the white col ...

What's the simplest method for adjusting the default font in Reactstrap?

Currently working on a MERN project and I want to customize the font used by Reactstrap for my React frontend. While I've come across solutions for altering Bootstrap 4's default fonts, I'm unsure how to implement them in Reactstrap. Any gui ...

Unable to apply margin right to React Material-UI table

I am struggling to add margin to the right of a mui table with no success. Below is the code I have used: <TableContainer> <Table sx={{ mr: 100 }} aria-label="customized table"> <TableHead> <Tabl ...

The upper 50% is malfunctioning because the parent height is set to auto

Having a bit of trouble with vertically centering a child div within its parent. I've been using this mixin: @mixin vertical-align { position: relative; top: 50%; -webkit-transform: translateY(-50%); -ms-transform: translateY(-50%); ...

Tips for adding a border to a table cell without disrupting the overall structure of the table

Looking for a way to dynamically apply borders to cells in my ng table without messing up the alignment. I've tried adjusting cell width, but what I really want is to keep the cells' sizes intact while adding an inner border. Here's the sim ...

Issue encountered while attempting to start React and Node.js: NPM error

I've encountered some errors in my Node.js and React.js project. I have a server and a React SPA, both working independently. When I use "concurrently" to start them together, I get the following errors: [0] npm ERR! missing script: servernpm run clie ...

What are the specific files I should modify for HTML/CSS in my Ruby application?

My application was initially created with an introduction from: http://guides.rubyonrails.org/getting_started.html I am now looking to add some color and style through CSS. I have located the JavaScript and CSS files, but I am unsure which file is respons ...

The header and footer are not extending across the entire width of the page

While testing on a responsive screen, I noticed that the header and footer both decrease in width instead of maintaining 100% width as intended. The issue only occurs when I reduce the width of the screen. body{ margin: 0; padding: 0; box-si ...

The scroll-to-top arrow remains concealed when the height of the html and body elements is set to 100

I recently added a scroll-to-top arrow using Jquery, and it's functioning flawlessly. However, I encountered an issue when I set body and html to a height of 100%, as it mysteriously disappears. View this fiddle for reference The HTML structure is a ...

Incorporating a background image into a Material UI theme with CSS styling

When customizing a theme in material UI, one can adjust or override it using the function createMuiTheme. Below is the complete file where this process is carried out: import { createMuiTheme } from '@material-ui/core/styles'; import purple from ...

What is the correct way to run npm and node on Windows 11? I keep encountering an error when attempting to execute npm install on my Windows system

I am encountering an error message when attempting to execute npm install or npm install nodejs-java on my Windows 11 system. Here are the versions: npm version - 9.6.1 node version - v18.15.0 Visual studio - 2017 Despite multiple attempts, I have been u ...

The rc-form package in npm is issuing a Warning for the getFieldDecorator method when `defaultValue` is not being used as an option

Currently, I am on the rc-form 2.4.8 version and I am utilizing the getFieldDecorator method in my codebase. However, an issue has arisen: Warning: defaultValue is not a valid property for getFieldDecorator; the correct use is to set value, so please uti ...

Combining two divs to share the same linear gradient and shadow effect

Greetings to all our valued partners! I am seeking guidance on how to achieve the following task for a web application I am developing: Within my webapp, I have designed a stylish NavBar similar to the examples depicted in the images (in AdobeXD it is di ...

Which approach is more efficient: storing fetched data in state or continuously re-fetching it using server functions in next.js 13?

Currently immersed in a project involving Next.js, I find myself questioning the most efficient data fetching method. In the latest version of Next.js, direct database data retrieval is enabled through server components. In contrast, older versions requi ...

Exploring how React dynamically alters class names within snapshots

I am encountering issues with my React JS test cases as the snapshots keep failing on different systems. The problem lies in the generation of random classnames and row-index values. - Snapshot + Received @@ -6,11 +6,11 @@ <div class="MuiG ...

Typescript error: The property 'set' is not found on type '{}'

Below is the code snippet from my store.tsx file: let store = {}; const globalStore = {}; globalStore.set = (key: string, value: string) => { store = { ...store, [key]: value }; } globalStore.get = (key) => { return store[key]; } export d ...

The program is unable to locate the file named npx create-react-app myapp

Whenever I attempt to create a React app using the command: npx create-react-app myapp An error message pops up stating: "PS C:\Users\yashj\OneDrive\Desktop\messaging_app> npx create-react-app myapp Program 'npx.cm ...