###前提
一枚もののLPのようなHPを作っています。
scrollify.jsとanimate.cssを使い、sectionが切り替わるときにページがめくれるようなアニメーションをつけました。
###発生している問題・エラーメッセージ
前述のアニメーションですが、PC上、またスマートフォン(Android)でもFire Foxならうまく表示されたのですが、スマートフォンのchromeだと高さがずれてしまい、次のsectionの上部が表示領域に食い込んでしまっている状態です。
スマートフォン(Android)でchromeをお使いの方は分かるかと思いますが、上のURLなどが記載されているツールバーが下にスクロールした際に表示されなくなります。
そのせいで読み込み時のwindowの高さと実際に表示されているwindowの高さにずれが生じ、問題が起こっているのだと思われます。
###該当のHTML
<!DOCTYPE HTML> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" /> <meta name="format-detection" content="telephone=no"/> <meta name="description" content="●●,●●"> <meta name="keywords" content="●●,●●"> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script type="text/javascript" src="js/animation.js"></script> <link rel="stylesheet" type="text/css" href="css/animate.css" /> <link rel="stylesheet" href="css/style.css" /> </head> <body> <div id="wrapper"> <section id="message" class="animated" data-section-name="message"> <div class="header"> <img class="small" src="images/index/main_img.jpg" /> <h1> <img class="head_logo01 animated" src="images/common/logo_mark.png" alt="" /> <img class="logo03 animated" src="images/common/logo_before.png" alt="" /> <img class="logo02 animated" src="images/common/logo_white.png" alt="" /> </h1> </div> <div class="content"> <div class="block_container clearfix"> <div class="block"> <p>ダミーテキスト</p> <p>ダミーテキスト</p> </div> </div> <div class="block_container clearfix"> <div class="block"> <p>ダミーテキスト</p> <p>ダミーテキスト</p> </div> </div> <div class="block_container clearfix"> <div class="block"> <p>ダミーテキスト</p> <p>ダミーテキスト</p> </div> </div> </div> </section> <!-- /#message --> <section id="works" class="animated" data-section-name="works"> <div class="title"> <img class="logo01 animated" src="images/common/logo_mark.png" alt="" /> <img class="logo02 animated" src="images/common/logo_black.png" alt="" /> <h2>ダミーテキスト</h2> </div> <div class="content"> <p>ダミーテキスト</p> <p>ダミーテキスト</p> </div> </section> <!-- /#works --> </div> <!-- /#wrapper --> <script type="text/javascript" src="js/jquery.scrollify.min.js"></script> <script type="text/javascript" src="js/jquery.inview.js"></script> <script type="text/javascript" src="js/jquery.easing.1.3.js"></script> <script type="text/javascript" src="js/scroll.js"></script> </body> </html>
###該当のCSS
style.css
@charset "utf-8"; /* ------------------------------- common ------------------------------- */ body, p { margin: 0; padding: 0; font-weight: normal; } img { border:0; vertical-align: top; } body { width: 100%; font-size: 0.9rem; font-family: "メイリオ",Meiryo,Osaka,"ヒラギノ角ゴ Pro W3","Hiragino Kaku Gothic Pro","MS Pゴシック","MS PGothic",sans-serif; color: #333; line-height: 1.5; -webkit-text-size-adjust: none; background-color: #000; letter-spacing: 0.3em; } a{ outline: none; text-decoration: none; } a:hover { text-decoration: none; } #wrapper { overflow: hidden; max-width: 1080px; margin: 0 auto; } h1 { margin: 0; } h2 { font-size: 150%; font-weight: normal; margin: 0; } h3 { font-weight: normal; margin: 0 0 3%; font-size: 100%; } h4 { font-weight: normal; margin: 0; font-family: "Times New Roman"; } /* -------------------------------- clearfix * ----------------------------- */ .clearfix:after { content: ""; display: block; height: 0; clear: both; } .clearfix{ display: block; *zoom: 1; } /* ------------------------------- section ------------------------------- */ section { background-color: #fff; animation-duration: .3s; -webkit-animation-duration: .3s; height: 100%; } .content { width: 60%; margin: 0 auto; } @media screen and (max-width: 640px) { .content { width: 94%; padding: 3%; } } .title { text-align: center; padding: 4% 0; } .title img.logo01 { max-width: 17%; width: auto; height: auto; margin: 0 auto; display: block; padding-right: 2.3%; } .title img.logo02 { max-width: 32%; width: auto; height: auto; margin: 0 auto 4%; display: block; animation-duration: 3s; -webkit-animation-duration: 3s; animation-delay: .5s; -webkit-animation-delay: .5s; } @media screen and (min-width: 1000px) { .title img.logo01 { max-width: 13%; } .title img.logo02 { max-width: 25%; } } /* ------------------------------- message -------------------------------- */ #message { background-color: #333; font-family: 'Sawarabi Mincho', serif; } .header{ position: relative; width: 100%; margin-bottom: 4%; } .header img { width: 100%; } .header img.head_logo01 { position: absolute; max-width: 18%; width: auto; height: auto; left: 46%; right: 0; top: 25%; margin: auto; animation-duration: 1.2s; -webkit-animation-duration: 1.2s; animation-delay: 1.5s; -webkit-animation-delay: 1.5s; } .header img.logo02 { position: absolute; max-width: 35%; width: auto; height: auto; left: 49%; right: 0; top: 40.85%; margin: auto; animation-duration: 3s; -webkit-animation-duration: 3s; animation-delay: 2.7s; -webkit-animation-delay: 2.7s; } .header img.logo03 { position: absolute; max-width: 68%; width: auto; height: auto; left: 0; right: 18.15%; top: 42.1%; margin: auto; animation-duration: 2s; -webkit-animation-duration: 2s; } @media screen and (min-width: 1000px) { .header { height: 600px; width: 100%; overflow: hidden; position: relative; } .header img.small { position: absolute; left: 0; bottom: -15%; right: 0; width: 100%; height: auto; } .header img.head_logo01 { top: 6%; right: 14%; max-width: 13%; } .header img.logo02 { top: 28%; left: 35%; max-width: 25%; } .header img.logo03 { max-width: 48%; right: 12.5%; top: 29.5%; } } #message .block { padding: 4%; margin-bottom: 4%; text-align: center; } #message .block p { padding: 1%; color: #fff; } /* ------------------------------- works -------------------------------- */ #works .content p { text-align: center; padding: 1.5% 0; } #works .content p:first-of-type { padding: 0 0 3%; }
###該当のjs
scroll.js
var option = { section : "section", // 対象を指定 easing: "linear", // イージング scrollSpeed: 250, // スクロール時の速度 scrollbars: true // スクロールバーを表示するか }; $(function() { $.scrollify(option); // scrollifyの実行 }); //ここからセクションをめくるアニメーションの設定 $(function(){ var before = $(window).scrollTop(); $(window).scroll(function(){ // #worksまでの高さを取得 var distanceTop = $('#works .title .logo02').offset().top - $(window).height(); // #worksに達しているかどうかを判別 if($(window).scrollTop() > distanceTop){ var after01 = $(window).scrollTop(); if(before > after01) { //上にスクロールしたとき $('#message').removeClass('rotateOutUpRight'); $('#message').addClass('rotateInDownRight'); } else if(before < after01) { //下にスクロールしたとき $('#message').removeClass('rotateInDownRight'); $('#message').addClass('rotateOutUpRight'); } before = after01; } else if($(window).scrollTop() < distanceTop) { $('#message').removeClass('rotateInDownRight'); $('#message').removeClass('rotateOutUpRight'); } }); });
###試したこと
animate.cssが問題かと思い、記述を消したりしましたが、どうもscrollify.jsが問題のようです。
「scrollify.js chrome ずれる」などで検索しましたがそれらしきものはありませんでした。
###お願いしたいこと
どうにかこの問題を解決する方法があれば教えていただけると幸いです。
たとえば、chromeのツールバーを抜いた高さを最初から取得する方法や、
いっそのことchromeのツールバーを固定できる方法など…
よろしくお願いいたします。

回答1件
あなたの回答
tips
プレビュー