How To Make Website With Animation | Moving Car Using CSS Animation | Moving car using html and css
HTML Code
<!DOCTYPE html>
<html>
<head>
<title>Moving car</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="hero">
<div class="highway"></div>
<div class="city"></div>
<div class="car">
<img src="car.png">
</div>
<div class="wheel">
<img src="wheel.png" class="back-wheel">
<img src="wheel.png" class="front-wheel">
</div>
</div>
</body>
</html>
CSS Code
*
{
padding: 0;
margin: 0;
}
.hero{
height: 100vh;
width: 100%;
background-image: url(sky.jpg);
background-size: cover;
background-position: center;
position: relative;
overflow-x: hidden;
}
.highway{
height: 200px;
width: 500%;
background-image: url(road.jpg);
position: absolute;
bottom: 0;
left: 0;
right: 0;
z-index: 1;
animation: highway 5s linear infinite;
}
@keyframes highway{
100%{
transform: translateX(-3400px);
}
}
.city{
height: 200px;
width: 500%;
background-image: url(city.png);
position: absolute;
bottom: 200px;
left: 0;
right: 0;
z-index: 1;
animation: city 20s linear infinite;
}
@keyframes city{
100%{
transform: translateX(-1400px);
}
}
.car{
width: 400px;
left: 50%;
bottom:100px;
position: absolute;
z-index: 2;
transform: translate(-50%);
}
.car img{
width: 100%;
animation: car 1s linear infinite;
}
@keyframes car{
100%{
transform: translateY(-1px);
}
50%{
transform: translateY(1px);
}
0%{
transform: translateY(-1px);
}
}
.wheel{
left: 50%;
bottom: 178px;
position: absolute;
z-index: 2;
transform: translateX(-50%);
}
.wheel img{
height: 72px;
width: 72px;
animation: wheel 1s linear infinite;
}
.back-wheel{
left: -165px;
position: absolute;
}
.front-wheel{
left: 80px;
position: absolute;
}
@keyframes wheel{
100%{
transform: rotate(360deg);
}
}
For To-Let : https://basabaribd.com
Our Another website: https://dm.basabaribd.com
Thanks For visit our website
Road disappears in mobile view. check out implementation here
ReplyDeletehttp://www.intimecab.com/
How can solve it?