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

80
Visualizações
Moving road background image

.bg
{
  width: 100vw;
  height: 100vh;
}
<div class="bg">
  <img src="https://www.roadsbridges.com/sites/rb/files/styles/content_type_page/public/Traffic_Safety_64.jpg?itok=a9CICO90" alt=""/>
</div>

Hi I wanna use the road image as a background but I want it too loop across the screen over and over infinitely as if the road is moving. What CSS or ReactJS code can I use to do that?

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

0

There are different ways to do it, look at this codepen https://codepen.io/konker/pen/Qozzrj

#road {
 opacity:.9;
 width: 120vw;
 height: 20vw;
 min-height:200px;
 background: #888;
 background-image: linear-gradient(
  rgba(0, 0, 0, 0.7) 0%,
  rgba(0, 0, 0, 0.2) 35%,
  rgba(80, 80, 80, 0.2) 50%,
  rgba(30, 30, 30, 0.4) 70%,
  rgba(60, 60, 60, 0.5) 87%,
  rgba(180, 180, 180, 0.5) 100%
 ),
 url("image url");
 background-size: 19vw auto;
 transform-origin: center top;
 transform: rotateX(45deg) translate(-20vw);
 animation: stripemove 0.2s linear infinite;
}

@keyframes stripemove {
 to {
   transform: rotateX(45deg) translate(0vw);
 }
}

Use the animation property like:

.bg img {
  height: 25vh;
  width: 200vw;
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 10;
  animation: moving 3s linear infinite 1s;
}

@keyframes moving {
  100% {
    transform: translateX(-100vw);
  }
}
about 4 years ago · Juan Pablo Isaza Relatório

0

I think you can use css property tranform-y and animations

about 4 years ago · Juan Pablo Isaza Relatório

0

This will definitely take that image and run it over and over again. without animating it.

.bg
{
  background: url("https://www.roadsbridges.com/sites/rb/files/styles/content_type_page/public/Traffic_Safety_64.jpg?itok=a9CICO90");
  width: 100vw;
  height: 100vh;
  background-size: 300px 100px;
}
<div class="bg">
</div>

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