Czy mógłby mi ktoś wytłumaczyć co robię źle i dlaczego kod nie działa. Chcę stworzyć płynne przesuwanie się drzew tak, aby dawało to złudzenie ruchu pojazdu.
html, body
{
height: 100%;
width: 100%;
overflow: hidden; /*---------------------*/
margin: 0;
}
.sky, .grass, .road
{
position: relative; /*-------------*/
}
.sky
{
background-color: skyblue;
height: 40%;
}
.grass
{
background-color: seagreen;
height: 30%;
}
.road
{
background: #1a1a1a; /*-------------*/
box-sizing: border-box; /*-------------*/
height: 30%;
border-top: 10px solid grey;
border-bottom: 10px solid grey;
width: 100%;
}
.lines
{
box-sizing: border-box;
border: 5px dashed #fff;
height: 0px;
width: 100%;
position: absolute;
top: 45%; /*-------------*/
}
.car
{
position: absolute;
top: -40px;
right: 120px;
animation: jump .6s 8s ease;
z-index: 100;
animation: car 1.5s linear infinite;
}
.tree
{
height: 160px;
width: 130px;
position: absolute;
}
.tree:nth-child(1)
{
top: -60px;
left: -530px;
animation: trees1 9s linear infinite;
}
.tree:nth-child(2)
{
top: 30px;
left: -130px;
animation: trees2 6s linear infinite;
}
@keyframes trees1 {
0% {
transform: translateX(0);
}
100% {
-o-transform: translateX(-o-calc(100%+530px));
-ms-transform: translateX(c-ms-alc(100%+530px));
-moz-transform: translateX(-moz-calc(100%+530px));
-webkit-transform: translateX(-webkit-calc(100%+530px));
transform: translateX(calc(100%+530px));
}
}
@keyframes trees2 {
0% {
transform: translateX(0);
}
100% {
-o-transform: translateX(-o-calc(100%+130px));
-ms-transform: translateX(c-ms-alc(100%+130px));
-moz-transform: translateX(-moz-calc(100%+130px));
-webkit-transform: translateX(-webkit-calc(100%+130px));
transform: translateX(calc(100%+130px));
}
}
@keyframes car
{
50%
{
transform: translateY(10px);
}
}