1. 程式人生 > 其它 >8.9前端之響應設計模式

8.9前端之響應設計模式

8.9前端之響應設計模式

什麼是響應設計模式(Responsive Web Design)

  • 響應式 web 設計會讓您的網頁在所有裝置上看起來都不錯

  • 響應式 web 設計僅使用 HTML 和 CSS

  • 響應式 web 設計並不是程式或 JavaScript

概括:

使用 CSS 和 HTML 調整大小、隱藏、縮小、放大或移動內容,以使其在任何螢幕上看起來都很好,則稱為響應式 Web 設計

  • RWD 能夠以可變尺寸傳遞網頁

  • RWD 對於平板和移動裝置是必需的


自己建立的例項

<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<style>
.city{
float: left;
margin: 5px;
padding: 15px;
width: 300px;
height: 300px;
border: 1px solid black;
border: 0;
}
.bcity{
float: left;
margin: 5px;
padding: 15px;
width: 300px;
height: 300px;
border: 1px solid black;
border: 1;
}
</style>
<title>ResponsiveDesignPracticeHtml</title>
</head>
<body>
<h1>This is a PracticeDemo</h1>
<h2>Resize this Response Page!</h2>
<br />

<div class="city">
<h2>ShenZhen</h2>
<p contenteditable="false">ShenZhen is a city and it is very prosperous</p>
<p contenteditable="false">It is It is the most populous city in China</p>
</div>

<div class="bcity">
<h2>LiuZhou</h2>
<p contenteditable="false">LiuZhou is a city in GuangXi province</p>
<p contenteditable="false">It is the second city in GuangXi province</p>
</div>

<div class="bcity">
<h2>NanNing</h2>
<p contenteditable="false">NanNing is a provincial capital of GuangXi province</p>
</div>
</body>
</html>

使用Bootstrap

  • 這是一個Css框架

  • 是最流行的開發響應式 web 的 HTML, CSS, 和 JS 框架。

  • 幫助開發在任何尺寸都外觀出眾的站點:顯示器、膝上型電腦、平板電腦或手機

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" />
<title></title>
</head>
<body>
<div class="container">
<div class="jumbotron">
<h1>This is a Demo</h1>
<p contenteditable="false">It is a responsive page!</p>
</div>
</div>

<div class="container">
<div class="row">
<div class="col-md-4">
<h2>ShenZhen</h2>
<p contenteditable="false">ShenZhen is a city and it is very prosperous</p>
<p contenteditable="false">It is It is the most populous city in China</p>
</div>
<div class="col-md-4">
<h2>LiuZhou</h2>Content
<p contenteditable="false">LiuZhou is a city in GuangXi province</p>
請輸入內容:<p contenteditable="true">
Content
</p>
</div>
<div class="col-md-4">
<h2>NanNing</h2>
<p contenteditable="false">NanNing is a provincial capital of GuangXi province</p>
</div>
</div>
</div>
</body>
</html>

It's a lonely road!!!