How To Create An Endless Road Animation Effect Only HTML And CSS
File structure:
- index.html
- style.css
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style.css">
<!--font awesome filup-->
<link rel="stylesheet" href="css/all.css">
<title>Endless road animation effect</title>
</head>
<body>
<div class="Endless">
<div class="shadow">
</div>
</div>
</body>
</html>
style.css: The following is the code for file “style.css” which is used in the above HTML code.
body{
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: #900C3F;
}
.Endless{
position: absolute;
width: 800px;
height: 160px;
background: #c70039;
transform-origin: bottom;
transform-style: preserve-3d;
transform: perspective(500px) rotateX(30deg);
}
.Endless::before{
content: '';
position: absolute;
top: 50%;
left: 0;
width: 100%;
height: 10px;
transform: translateY(-50%);
background: linear-gradient(90deg, #fff 0%,#fff 70%,#525252 70%,#525252 100% );
background-size: 120px;
animation: animate 0.5s linear infinite;
}
@keyframes animate {
0%{
background-position: 0px;
}
100%{
background-position: -120px;
}
}
.Endless::after{
content: '';
position: absolute;
width: 100%;
height: 30px;
background: #333;
bottom: -30px;
transform-origin: top;
transform: perspective(500px) rotate(-250px);
}
.shadow{
position: absolute;
bottom: -93px;
left: 50%;
transform: translateX(-50%);
height: 60px;
background: linear-gradient(#000,transparent);
width: 95%;
opacity: 0.5;
}
1 Comments
Really this is a very good content
ReplyDelete