サビリピソース解析の3回目。コンテンツ内のヘッダー画像について解説していきます。
前回の記事
2.Bootstrapグローバルナビゲーション(グローバルナビ Navbar):サビリピ
アプリURL
サビリピ – Youtube動画で大好きな曲のサビを無限
ヘッダー画像のHTMLと画像
<?php if(empty($_SERVER['QUERY_STRING'])): ?>
<div class="text-center" style="background:url('http://app.it-ti.work/asset/img/sabi-top.jpg') no-repeat center center;background-size:cover; margin:-24px 0 30px;padding:68px 0;color:#fff;">
<h1 style="font-size:50px;"><?php echo $site_name ?></h1>
<div class="form-group" style="margin-bottom:45px;">
曲のサビを無限リピートしよう
</div>
<div class="form-group">
<a href="#create-video" class="btn btn-danger">作成済みの曲を聴く</a>
</div>
<div class="form-group">
<button class="btn btn-xs btn-default" id="share" type="button"><span class="glyphicon glyphicon-share-alt"></span> 共有する</button>
</div>
</div>
<?php endif; ?>
1行目:
トップページのみ画像を表示する処理です。クエリパラメータが存在するかどうかPHPで判定し、パラメータ無し(トップページ)の場合に画像を表示しています。
2行目:
classにbootstrapで用意されている中央寄せのclass「text-center」を指定し、文字、ボタンを中央寄せで表示しています。
ペラのWEBアプリらしくstyle属性を指定し、cssをタグに直接(インラインで)書いています。
3行目〜6行目:
サイト名、サブタイトルを設定しています。こちらもcssをインラインで書いています。
8行目:
「作成済みの曲を聴く」ボタン。aタグにページ内リンクを設定し、クリックすると以下の作成済み一覧にスクロールします。
11行目:
「共有する」ボタン。クリックするとbootstrapのモーダルウィンドウを表示し、共有リンクとソーシャルサイトのボタンを表示します。
モーダルウィンドウのソース
<!-- 共有ボタンクリック時に表示されるダイアログ -->
<div class="modal fade" id="share_box">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">リンクを共有</h4>
</div>
<div class="modal-body">
<div class="form-group">
<input class="form-control" id="link-text" value="<?php echo h($full_url); ?>">
</div>
<div class="form-group text-center">
<ul class="nav nav-pills">
<li class="list-group-item">
<a href="http://b.hatena.ne.jp/entry/<?php $url ?>" class="hatena-bookmark-button" data-hatena-bookmark-layout="vertical-normal" data-hatena-bookmark-lang="ja" title="このエントリーをはてなブックマークに追加"><img src="https://b.st-hatena.com/images/entry-button/button-only@2x.png" alt="このエントリーをはてなブックマークに追加" width="20" height="20" style="border: none;" /></a><script type="text/javascript" src="https://b.st-hatena.com/js/bookmark_button.js" charset="utf-8" async="async"></script>
</li>
<li class="list-group-item">
<div class="fb-like" data-href="<?php echo $full_url ?>" data-layout="box_count" data-action="like" data-size="small" data-show-faces="true" data-share="true"></div>
</li>
<li class="list-group-item">
<a href="https://twitter.com/share" class="twitter-share-button" data-url="<?php echo $url ?>" data-text="<?php echo $title.' '.$full_url; ?>">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
</li>
<li class="list-group-item">
<div class="line-it-button" data-lang="ja" data-type="like" data-url="<?php echo $full_url ?>" data-share="true" style="display: none;"></div>
<script src="https://d.line-scdn.net/r/web/social-plugin/js/thirdparty/loader.min.js" async="async" defer="defer"></script>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
画像サイズが合えばbootstrapの「Jumbotron」コンポーネントで以下の様な書き方もできます。
<div class="jumbotron" style="background:url('画像.jpg') no-repeat center center;background-size:cover;">
<h1>Hello, world!</h1>
<p>...</p>
<p><a class="btn btn-primary btn-lg" href="#" role="button">Learn more</a></p>
</div>
1行目のクラスに「jumbotron」を指定する。
参考サイト:Bootstrapで横幅いっぱいに画像を表示しよう!ジャンボトロン(jumbotron)の設置方法
以上でサビリピヘッダー画像の解説は終了です。
次回はYotube動画の設定方法について解説します。
コメントを残す