Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

197
Visualizações
How can I add a (CSS) cursor: property to elements in an array?

I am trying to style the data array, so that when you hover over it the cursor is set to cursor: grab;. I tried using different elements to make it happen none worked , .li{}, .ol{}, MediaComponent{},img{},imgSrc{},data{},div{}. The only one that worked for me was *.{}, however the problem with this is that the cursor remains on the grab property for the rest of the elements on the page. I'm trying to code it so that the cursor:grab; element only pertains to the data array.

import React, { Component,useRef, setStatus, status } from 'react';
import './Turkish.css';

import turk1 from "./music/turk1.mp3";
import turk2 from "./music/turk2.mp3"
import turk3 from "./music/turk3.mp3"
import turk4 from "./music/turk4.mp3"

const data = [
    { imgSrc: 'turk1.png', audioSrc: turk1 },
    { imgSrc: 'turk2.png', audioSrc: turk3 },
    { imgSrc: 'turk3.png', audioSrc: turk4 },
    { imgSrc: 'turk4.png', audioSrc: turk2 },
  ];
  
  export default class Turkish extends Component {
    render() {
      return (
        <div>
          <ol>
            {data.map(({ imgSrc, audioSrc }) => (
              <MediaComponent imgSrc={imgSrc} audioSrc={audioSrc} />
            ))}
          </ol>
        </div>
      );
    }
  }
  
  const MediaComponent = ({ imgSrc, audioSrc }) => {
    const audioRef = useRef(null);
    const toggleAudio = () =>
      audioRef.current === null
        ? console.log("Audio component is not loaded yet.")
        : audioRef.current.paused
        ? audioRef.current.play()
        : audioRef.current.pause();

        
            return (
              <li>
                <img src={imgSrc} onClick={toggleAudio} />
                <audio
                  ref={audioRef}
                  src={audioSrc}
                  onLoad={() => setStatus({ ...status, isLoaded: true })}
                  onPlay={() => setStatus({ ...status, isPlaying: true })}
                  onPause={() => setStatus({ ...status, isPlaying: false })}
                  onError={() => setStatus({ ...status, error: true })}
                />
              </li>
            );
          };

Any thoughts?

Thank You

-Zpo

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It should work with ol, I guess you are making mistake in your CSS file. To be sure give className to your ol and pass cursor: grab in CSS

<ol className="olGrab">
   {data.map(({ imgSrc, audioSrc }) => (
    <MediaComponent imgSrc={imgSrc} audioSrc={audioSrc} />
   ))}
</ol>

In CSS

.olGrab { cursor: grab;}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda