Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

85
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

0

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

about 4 years ago · Juan Pablo Isaza Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda