2015-07-19 26 views
0

我在頁面上使用了滾動條。移動設備上的頁面顯示一個很大的空間,在您第一次滾動它時不會滾動。訪問了很多提供解決方案的網站,包括StackOverflow和@ Prinzhorn自己的評論,但有些我無法解決移動設備(Android,iPhone)上的問題。 這裏是HTML:Skroller在手機上創建大型空白空間

<div id="skrollr-body"> 
<div id="eidwish1" class="centered" data-300="width:100%; background-image:linear-gradient(0deg, hsl(0, 100%, 50%), hsl(40, 50%, 50%));" data-2000="width:0%; background-image:linear-gradient(3600deg, hsl(360, 100%, 50%), hsl(400, 100%, 50%));"><h1 class="text-center heading2 wow fadeInDown" data-0="display:block;" data-1500="display:none;">This Eid send your loved ones...</h1></div> 
<div id="eidwish2" class="centered" data-2000="width:100%;" data-2500="width:0%;"><h1 class="text-center heading2 wow fadeInUp" data-0="background-image:linear-gradient(0deg, hsl(0, 100%, 50%), hsl(40, 50%, 50%));" data-2500="background-image:linear-gradient(3600deg, hsl(360, 100%, 50%), hsl(400, 100%, 50%));">a personalized Greeting Card!</h1> 
<div id="crescent" class="centered" data-1500="top:-100px;" data-2000="top:-200px;"></div> 
</div> 
<div id="ribbon-left" class="ribbon" data-2500="width:0%;" data-3500="width:50%;"></div> 
<div id="ribbon-right" class="ribbon" data-2500="width:0%;" data-3500="width:50%;"></div> 
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="337px" height="200px"> 
</svg> 
<div id="pattern1" class="centered" data-2500=" height:100%; "data-3500="height:0%;"></div> 
<div id="pattern2" class="centered"></div> 
<div id="eidwish3" class="centered" data-4000="width:0px;height:0px; "data-5000="width:700px;height:700px;"></div> 
<h1 class="text-center headerUp wow lightSpeedIn" data-0="display:none;" data-4000="display:block;"><img src="logo.png" alt="logo"/><span clss="toggle-green">THINK GREEN </span><span class="toggle-blue">PRINT GREEN</span></br><small><i>use "EID-2015" promo code when you checkout</i></small></h1> 
<h1 class="text-center discount wow rollIn" data-0="display:none;" data-4000="display:block;">We are Giving Away 25% discount</h1> 
<a class="button btn-success buy-now text-center wow jello" data-wow-iteration="10" data-wow-duration="3000ms" data-0="display:none;" data-4000="display:block;" href="Greeting Cards">See All Card Designs</a> 
<a class="copyright" href="http://example.com"> 
<img src="http://example.com/logo.png" alt="logo"/> 
<br>Copyright © example.com 2015-16</a> 
</div> 

這是JS:

和CSS:

html, body {padding:0;margin:0; 
k} 
body {overflow:auto; height:7600px; 
} 
#skrollr-body {min-height: 1px; float: left; width:100%; height:100%; 
} 
#skrollrk-body div {overflow:hidden; position:absolute; 
} 
.centered { top:0; bottom:0; left:0; right:0; margin:auto; 
} 
#eidwish1 {background: #000 center center no-repeat ; z-index:5; 
} 
#eidwish2 {background: #000 url('wish2.png') center bottom no-repeat ; z-index:4; box-shadow: 0 0 0 20px #FF0000; background-size: cover; 
} 
#crescent {width:100%; background:url('crescent2.png') no-repeat; margin-top:0px; 
} 
#pattern1 { background:url('wish3.jpg') ; z-index:2; background-attachment:fixed; background-size: cover; 
} 
.ribbon {background:#FF0000; height:40px; top:50%; margin-top:-20px; z-index:3;} 
#ribbon-left {left:0 
} 
#ribbon-right {right:0 
} 
small { color: #fff; 
} 
svg {position:absolute; z-index:5; left:50%; top:50%; margin-left:-170px; margin-top:-180px 
} 
#pattern2 { background:url('wish4.jpg'); z-index:1; background-size: cover 
} 
#eidwish3 {background:#FF0000 url('wish5.jpg') no-repeat center center; z-index:10; border-radius:50%; background-size: cover 
} 

我被困在這許多天。我已經閱讀了幾乎所有關於此的線索,並試圖做同樣的事情,但它不能解決我的問題。請幫忙!

回答

1

我完全和你在這個話題上。哦,我希望我可以跟某個人談論skrollr。以下是我對Skrollr和Mobile的一些瞭解:

然而,CSS佈局,特別是按百分比的寬度,被 相對於佈局視口,其比 視覺viewport.Thus元件相當寬的計算最初佔用佈局視圖寬度 ,並且您的CSS將被解釋爲屏幕爲 明顯比手機屏幕寬。這可以確保您的網站佈局的行爲與在桌面瀏覽器上的佈局相同。

佈局視口有多寬?每個瀏覽器都不相同。 Safari iPhone使用980像素,Opera 850像素,Android WebKit 800像素和IE 974像素。

  • 這是一個很大的交易。如果您的桌面和移動版面/視覺視口的大小相同,那麼您可以使用觸摸系統使您的網站在移動設備中起到實質性的作用。它的外觀和功能與桌面滾動非常相似。
  • 如果這些視口的寬度大不相同,那麼它是不可行的。我有一個完全由高度控制的網站,所以我運氣不好。最後,我在頁面底部添加了一些「靜態」屏幕。我添加了兩個類(.my_website_mobile和.my_website_desktop),我會根據需要display: block;display: none;。我很不高興,但它工作。
  • 在移動設備上,具有背景圖像的div不能有background-position: fixed這對於桌面瀏覽器移動模擬器工具來說效果很好,但在真正的移動設備上會失敗。 (經驗教訓...)
  • 其他可能會在手機上出現奇怪表現的函數:溢出和可視視口對於位置和大小,我使用了很多vw(視口寬度)和vh(視口高度)高度,而不是% 。這些在桌面上是有意義的,而不是在移動設備上。
  • 提醒,skrollr-body在skrollr初始化時獲取style="-webkit-transform: translate(0px, 0px) translateZ(0px); transform: translate(0px, 0px) translateZ(0px);"
  • 如果您在移動設備上,則:skrollr初始化後:<html class="skrollr skrollr-mobile" style="overflow: hidden;" ><body style="overflow: hidden;">
  • 如果您位於桌面設備上,則:skrollr初始化後:<html class="skrollr skrollr-desktop"><body style="height: 12345px;">

我還沒有挖掘到您的具體代碼,但如果你想多說話,通過電子郵件與我聯繫(檢查我的個人資料...)我完全爲它。在我能夠排除您的代碼故障之前,我需要更換機器和我的位置...