2016年2月9日 星期二

web building tutorial

What We Will Do

We will build a web site
  • We will create web pages using HTML
  • We will add a consistent style using CSS
  • We will add computer code using JavaScript
  • We will add static data pages
  • We will fetch data using Http
  • We will fetch data using AppML
  • We will fetch data using SQL
  網站內容大概長得像這樣



Create a CSS Style Sheet

body {
    font-family: "Trebuchet MS", Verdana, sans-serif;
    font-size: 16px;
    background-color: dimgrey;
    color: #696969;
    padding: 3px;
}

#main {
    padding: 5px;
    padding-left:  15px;
    padding-right: 15px;
    background-color: #ffffff;
    border-radius: 0 0 5px 5px;
}

h1 {
    font-family: Georgia, serif;
    border-bottom: 3px solid #cc9900;
    color: #996600;
    font-size: 30px;
}
The CSS file above defines the styles to be used for:
  • The HTML body element <body>
  • The HTML element with id="main"
  • The HTML heading element <h1>
edit the file index.html

<head>
  <title>Our Company</title>
  <link href="site.css" rel="stylesheet">
</head>

<body>

  <div id="main">
  <h1>Welcome to Our Company</h1> 
   .....
  <p>Live Data (Files and Databases)</p>
  </div>

</body>
</html>

Edit the About Page

To complete your work, do the same changes in about.html.
1. Add a link to the style sheet.
2. Add a <div id="main"> element.

about about.html

<!DOCTYPE html>
<html>
<head>
  <title>About</title>
  <link href="site.css" rel="stylesheet">
</head>

<body>

  <div id="main">
  <h1>About Us</h1>
  <p>Lorem Ipsum Porem Lorem Ipsum Porem</p>
  </div>

</body>
</html>

Adding Code (JavaScript)


What We Will Do

In this chapter we will:
  • Create some computer code (JavaScript)
  • Add a link to the script in your pages


Create JavaScript

create a new file named script.js

edit script.js
==============================================================
document.getElementById("foot01").innerHTML =
"<p>&copy;  " + new Date().getFullYear() + " W3Schools. All rights reserved.</p>";
==========================================

Edit the Home Page


edit the file index.html

<div id="main">
 ........
  <p>Live Data (Files and Databases)</p>
  <footer id="foot01"></footer>
</div>

<script src="script.js"></script>

</body>

Web Building - Adding a Data Page


What We Will Do

In this chapter we will:
  • Add a data page to the web site
edit site.css

Create a Data Page

create a new file named customers.html

add the following content to customers.html

customers.html

<!DOCTYPE html>
<html>

<head>
  <title>Customers</title>
  <meta charset="UTF-8">
  <link href="site.css" rel="stylesheet">
</head>

<body>

<div id="main">
<h1>Customers</h1>

<table>
<tr>
  <th>Name</th>
  <th>City</th>
  <th>Country</th>
</tr>
<tr>
  <td>Alfreds Futterkiste</td>
  <td>Berlin</td>
  <td>Germany</td>
</tr>
<tr>
  <td>Berglunds snabbköp</td>
  <td>Luleå</td>
  <td>Sweden</td>
</tr>
<tr>
  <td>Centro comercial Moctezuma</td>
  <td>México D.F.</td>
  <td>Mexico</td>
</tr>
<tr>
  <td>Ernst Handel</td>
  <td>Graz</td>
  <td>Austria</td>
</tr>
<tr>
  <td>FISSA Fabrica Inter. Salchichas S.A.</td>
  <td>Madrid</td>
  <td>Spain</td>
</tr>
<tr>
  <td>Galería del gastrónomo</td>
  <td>Barcelona</td>
  <td>Spain</td>
</tr>
<tr>
  <td>Island Trading</td>
  <td>Cowes</td>
  <td>UK</td>
</tr>
<tr>
  <td>Königlich Essen</td>
  <td>Brandenburg</td>
  <td>Germany</td>
</tr>
<tr>
  <td>Laughing Bacchus Wine Cellars</td>
  <td>Vancouver</td>
  <td>Canada</td>
</tr>
<tr>
  <td>Magazzini Alimentari Riuniti</td>
  <td>Bergamo</td>
  <td>Italy</td>
</tr>
<tr>
  <td>North/South</td>
  <td>London</td>
  <td>UK</td>
</tr>
<tr>
  <td>Paris spécialités</td>
  <td>Paris</td>
  <td>France</td>
</tr>
<tr>
  <td>Rattlesnake Canyon Grocery</td>
  <td>Albuquerque</td>
  <td>USA</td>
</tr>
<tr>
  <td>Simons bistro</td>
  <td>København</td>
  <td>Denmark</td>
</tr>
<tr>
  <td>The Big Cheese</td>
  <td>Portland</td>
  <td>USA</td>
  </tr>
<tr>
  <td>Vaffeljernet</td>
  <td>Århus</td>
  <td>Denmark</td>
</tr>
<tr>
  <td>Wolski Zajazd</td>
  <td>Warszawa</td>
  <td>Poland</td>
</tr>
</table>

<footer id="foot01"></footer>
</div>

<script src="script.js"></script>

</body>
</html>

Web Building - Adding Navigation


What We Will Do

In this chapter we will:
  • Add a navigation menu
edit  script.js
   add the following content into script.js
===================================
   document.getElementById("nav01").innerHTML =
"<ul id='menu'>" +
"<li><a href='index.html'>Home</a></li>" +
"<li><a href='customers.html'>Data</a></li>" +
"<li><a href='about.html'>About</a></li>" +
"</ul>";
===============================================

edit your style sheet site.css
Add the following to the file content:

==================================
ul#menu {
    padding: 0;
    margin-bottom: 11px;
}

ul#menu li {
    display: inline;
    margin-right: 3px;
}

ul#menu li a {
    background-color: #ffffff;
    padding: 10px 20px;
    text-decoration: none;
    color: #696969;
    border-radius: 4px 4px 0 0;
}

ul#menu li a:hover {
    color: white;
    background-color: black;
}
=================================

edit your index.html

add <nav id="nav01"></nav> into index.html
================================
<body>

<nav id="nav01"></nav>

<div id="main">
=================================


Edit All Pages

  edit customers.html and about.html

  add  <nav id="nav01"></nav>

Reference : http://www.w3schools.com/website/

沒有留言:

張貼留言