Backgroundimage not working on React

Asked

Viewed 12 times

0

I have an application that has the image in the same component folder, as in the image:inserir a descrição da imagem aqui

And I’m using the following inline code to put this image as background:

   function App() {
  // Imagem carregada da mesma pasta
  const Background = './move-it.png';
  return (
    <div>

      {/* Codigo inline tentando acessar a imagem */}
      <div className="caixa" style={{ backgroundImage: 'url(' + Background + ')' }}>
        teste
      </div>
    </div>
  );
}

export default App;

But in the execution, it looks something like: Porem, na execução, fica algo como

The only style I defined was:

.caixa {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100px;
  height: 100px;
  
}
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.