Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

78
Views
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 answers
Answer question

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 Report

0

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

about 4 years ago · Juan Pablo Isaza Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!