在行動裝置(如手機、平板等)盛行的一開始,我首先注意到的是 jQuery Mobile 的解決方式,但是同時“它”也讓我猶豫是否要全力投入,猶豫的原因就是系統開發人員必須要開法兩套以上的介面以符合多種設備,這真是痛苦到了極點。
在學習 jQuery Mobile 的同時也注意到了一種新概念的興起,那就是 Responsive Web Design,這個概念基本上就是我前一段所說的,設計得好,寫一套程式就可以符合多種常見設備的介面。既然這個概念這麼好,馬上就有許多開發者投入並設計出相關的 framework(或者把它想成程式庫也可以)。Google 了一下,推薦的名單中出現了 Bootstrap,查了一下相關文件以及討論,看起來資料不少,那麼就開始試試看了。
Bootstrap 的安裝,其實是不需要安裝的。雖然我們可以把檔案下載下來,但是也可以直接使用放在網路上的版本,由於我們只是練習,所以就不安裝了。在這裡,所謂的安裝,指的是把一個支援 Boostrap 的網頁給建構出來,而這個 template 如下所示:
<!DOCTYPE html>
<html lang="Big5">
<head>
<meta charset="Big5">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Bootstrap 101 Template</title>
<!-- Bootstrap -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<h1>Hello, world!</h1>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
</body>
</html>