2017-11-27 15 views
0

デスクトップPCを使用しているときとiphoneをランドスケープで使用しているときに、私のcss3アニメーション文字が異なる場所にある理由は、ここでCssアニメーションがモバイルとPCのデスクトップで異なる場所

はアニメーション

<!DOCTYPE html> 
 
<head> 
 
    <title>Basket Example</title> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
 
</head> 
 
<style> 
 
    * { 
 
    box-sizing: border-box; 
 
    -webkit-box-sizing 
 
    -moz-box-sizing: border-box; 
 
} 
 
html, body{ 
 
    height: 100%; 
 
    width:100%; 
 
    overflow: hidden; 
 
    margin: 0; 
 
} 
 

 
.grass, .sky, .road{ 
 
    position: relative; 
 
} 
 

 
.sky{ 
 
    height: 40%; 
 
    background: skyblue; 
 
} 
 

 
.grass{ 
 
    height: 30%; 
 
    background: seagreen; 
 
} 
 

 
.road{ 
 
    height: 30%; 
 
    background: dimgrey; 
 
    box-sizing: border-box; 
 
    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%; 
 
} 
 
.horror2 { 
 
    position: absolute; 
 
    top: -90px; 
 
    left: 0px; 
 
    animation: drive 3s both 2s infinite linear, 
 
    jump 0.3s 4s ease; 
 

 
} 
 
    
 
.bike2{ 
 
position:absolute; 
 
top: -7px; 
 
left:0px; 
 
animation: drive 5s; 
 
animation-fill-mode: both; 
 
animation-iteration-count: infinite; 
 
animation-timing-function:linear; 
 

 
} 
 
.cloud{ 
 
position: absolute; 
 
} 
 

 
.cloud:nth-child(1){ 
 
width: 200px; 
 
top: 120px; 
 
opacity: 0.5; 
 
animation: wind 80s linear infinite reverse; 
 
} 
 
    
 
    .cloud:nth-child(2){ 
 
width: 300px; 
 
top: 0px; 
 
    animation: wind 50s linear infinite reverse; 
 

 
} 
 

 

 
@keyframes drive{ 
 
from{ transform: translateX(-200px)} 
 
to{ transform: translateX(1600px)} 
 

 
} 
 
@keyframes wind{ 
 
from{left: -300px} 
 
to{left: 100%} 
 
} 
 

 
@keyframes jump{ 
 
0% { top: -40px} 
 
50% { top: -100px} 
 
100%{ top: -40px} 
 
} 
 
@media only screen and (orientation: landscape) { 
 
    
 
html, body{ 
 
    height: 100%; 
 
    width:100%; 
 
    overflow: hidden; 
 
    margin: 0; 
 
} 
 

 
.grass, .sky, .road{ 
 
    position: relative; 
 
} 
 

 
.sky{ 
 
    height: 40%; 
 
    background: skyblue; 
 
} 
 

 
.grass{ 
 
    height: 30%; 
 
    background: seagreen; 
 
} 
 

 
.road{ 
 
    height: 30%; 
 
    background: dimgrey; 
 
    box-sizing: border-box; 
 
    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%; 
 
} 
 
.horror2 { 
 
    position: absolute; 
 
    top: -40px; 
 
    left: 0px; 
 
    animation: drive 3s both 2s infinite linear, 
 
    jump 0.3s 4s ease; 
 

 
} 
 
    
 
.bike2{ 
 
position:absolute; 
 
top: 80px; 
 
left:0px; 
 
animation: drive 5s; 
 
animation-fill-mode: both; 
 
animation-iteration-count: infinite; 
 
animation-timing-function:linear; 
 

 
} 
 
.cloud{ 
 
position: absolute; 
 
} 
 

 
.cloud:nth-child(1){ 
 
width: 200px; 
 
top: 120px; 
 
opacity: 0.5; 
 
animation: wind 80s linear infinite reverse; 
 
} 
 
    
 
    .cloud:nth-child(2){ 
 
width: 300px; 
 
top: 0px; 
 
    animation: wind 50s linear infinite reverse; 
 

 
} 
 

 

 
@keyframes drive{ 
 
from{ transform: translateX(-200px)} 
 
to{ transform: translateX(1600px)} 
 

 
} 
 
@keyframes wind{ 
 
from{left: -300px} 
 
to{left: 100%} 
 
} 
 

 
@keyframes jump{ 
 
0% { top: -40px} 
 
50% { top: -100px} 
 
100%{ top: -40px} 
 
}} 
 
</style> 
 
<body> 
 
    <div class="sky"> 
 
    <img class="cloud" src="http://www.cc.puv.fi/~e1401168/css3animation/img/cloud.png"> 
 
    <img class="cloud" src="http://www.cc.puv.fi/~e1401168/css3animation/img/cloud.png"> 
 
    </div> 
 
    <div class="grass"></div> 
 
    <div class="road"> 
 
    <div class="lines"></div> 
 
\t <img class="horror2" src="http://www.cc.puv.fi/~e1401168/css3animation/img/horror2.png"> 
 
\t <img class="bike2" src="http://www.cc.puv.fi/~e1401168/css3animation/img/bike2.png"> 
 

 
</div> 
 
    
 
</body> 
 
</html>

+0

固定値とパーセント値が使用されているため、その理由が考えられます –

答えて

0

デスクトップのサイズと景観モバイル工夫のサイズは非常にあなたの絶対位置の項目がになるつもりはありませんが、ほぼ同じではありませんです同じ場所。

おそらくcss media queriesを見て、あなたのdivを希望の領域に絶対配置してください。

関連する問題