W3.CSS - モバイルアプリの構築

❮ 前章へ 次章へ ❯

Movies 2014

Frozen

response to the animations was ridiculous.


Fault in Our Stars

Touching, gripping and genuinely well made.


Avengers

A huge success for Marvel and Disney.


基本的なモバイル・ページの作成

<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<body style="max-width:400px">
<!-- Content goes here -->
</body>
</html>

style 属性の "max-width:400px" は、小型の携帯電話をシミュレートします。それは、後で削除されます。


コンテンツの追加

例 (古典的な HTML 要素の使用)

<div class="w3-container">
  <h1>Movies 2014</h1>
</div>

<div class="w3-row">
  <div class="w3-col s3">
    <img src="img_avatar.jpg">
  </div>
  <div class="w3-col s9 w3-container">
    <h3>Frozen</h3>
      <p>The response to the animations was ridiculous.</p>
  </div>
</div>

<div class="w3-container">
  <h3>Footer</h3>
</div>
Try It Yourself ❯

例 (セマンティックな HTML 要素の使用)

<header class="w3-container">
  <h1>Header</h1>
</header>

<div class="w3-row">
  <div class="w3-col s3">
    <img src="img_avatar.jpg">
  </div>
  <div class="w3-col s9 w3-container">
    <h3>Frozen</h3>
      <p>The response to the animations was ridiculous.</p>
  </div>
</div>

<footer class="w3-container">
  <h3>Footer</h3>
</footer>

</body>
</html>
Try It Yourself ❯

カラー・テーマの追加

例s

<link rel="stylesheet" href="http://www.w3schools.com/lib/w3-theme-blue.css">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3-theme-red.css">
Try It Yourself ❯

カラー・テーマの詳細については、W3.CSS カラー をご覧ください。


アイコン・ライブラリの追加

<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css">

<h1>
  <i class="fa fa-bars"></i> Header
</h1>
Try It Yourself ❯

この例では、Font Awesome アイコンを使用していますが、どのようなアイコンライブラリでも使用することができます。


その他のスタイルを追加

<img class="w3-cicle" src="img_avatar.jpg" alt="avatar">

<h3 class="w3-text-theme">Frozen</h3>
Try It Yourself ❯

サイド・ナビゲーションの追加

<nav class="w3-sidenav w3-card-2 w3-white" style="width:30%">
<div class="w3-red">
  <a href="javascript:void(0)" onclick="w3_close()"
  class="w3-closenav w3-right w3-xlarge">X</a>
    <div class="w3-padding-large w3-center">
      <img class="w3-circle" src="img_avatar.jpg" alt="avatar">
   </div>
  </div>
<br>
<a href="#">Home</a>
<a href="#">Friends</a>
<a href="#">Messages</a>
</nav>

<script>
function w3_open() {
    document.getElementById("mySidenav").style.display = "block";
}

function w3_close() {
    document.getElementById("mySidenav").style.display = "none";
}
</script>
Try It Yourself ❯

サイド・ナビゲーションを隠す

<nav class="w3-sidenav w3-card-2 w3-white" style="width:30%;display:none">
Try It Yourself ❯

ナビゲーション、ヘッダーとフッターの固定

<header class="w3-top">

<nav class="w3-top">

<footer class="w3-bottom">
Try It Yourself ❯

❮ 前章へ 次章へ ❯