W3C中文教程
全球最大最新的中文 Web 技术教程
HTML CSS SQL PHP COLORS MYSQL BOOTSTRAP
 

W3.CSS - 构建移动应用



Movies 2014

Frozen

The response to the animations was ridiculous.


The Fault in Our Stars

Touching, gripping and genuinely well made.


The Avengers

A huge success for Marvel and Disney.

Footer


创建基本移动页面

Example

<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://cdn.w3schools.wang/w3.css">
<body style="max-width:400px">
<!-- Content goes here -->
</body>
</html>
Note 样式属性 "max-width:400px" 用来模拟一个小手机。稍后会将它删除。

添加内容

Example (使用经典的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>
尝试一下 »

Example (使用语义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>
尝试一下 »

添加颜色主题

Examples

<link rel="stylesheet" href="http://res.w3schools.wang/cate/w3css/w3-theme-blue.css">
<link rel="stylesheet" href="http://res.w3schools.wang/cate/w3css/w3-theme-red.css">
尝试一下 »
Note 如果阅读更多关于颜色主题的内容,请查看 W3.CSS 颜色

添加图标库

Example

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

<h1>
  <i class="fa fa-bars"></i> Header
</h1>
尝试一下 »
Note 此实例使用的是 Font Awesome 图标。您可以使用任何图标库。

添加更多样式

Example

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

<h3 class="w3-text-theme">Frozen</h3>
尝试一下 »

添加侧导航

Example

<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">&times;</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() {
    var x = document.getElementsByClassName("w3-sidenav")[0];
    x.style.display = "block";
}
function w3_close() {
    var x = document.getElementsByClassName("w3-sidenav")[0];
    x.style.display = "none";
}
</script>
尝试一下 »

隐藏侧导航

Example

<nav class="w3-sidenav w3-card-2 w3-white" style="width:30%;display:none">
尝试一下 »

固定导航,页眉和页脚

Example

<header class="w3-top">

<nav class="w3-top">

<footer class="w3-bottom">
尝试一下 »