http.createServer(function(req, res){ res.writeHead(200, {"Content-Type": "text/html"}); res.write("<h2>Hello world.</h2><p>This is the main content.</p>"); res.end(); }).listen(8080);
// 以下寫在 news.js 內 // 建立環境 var express = require("express"); var router = express.Router();
// 設定各項子路徑的回應 router.get("/breaking", function(req, res){ res.send("<h2>Latest news you should know.</h2>"); }); router.get("/international", function(req, res){ res.send("<h2>What's new around the world?</h2>"); });
#container > div { background-color: #8ca0ff; padding: 5px; }
HTML:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
<divid="container"> <div> Item as wide as the content, but at most 300 pixels. 與內容同寬,但最多到 300px </div> <div> Item with flexible width but a minimum of 200 pixels. 寬度會彈性變動,最少寬 200px </div> <div> Inflexible item of 150 pixels width. 就是 150px,不會變動 </div> </div>