CSS_06_响应式Web设计



响应式 Web 设计 - Viewport


什么是 Viewport?

viewport 是用户网页的可视区域

viewport 翻译为中文可以叫做"视区"。

手机浏览器是把 页面 放在一个虚拟的"窗口"(viewport)中,

通常这个虚拟的"窗口"(viewport)要比 屏幕

这样就不用把每个网页挤到很小的窗口中(这样会破坏没有针对手机浏览器优化的网页的布局),

用户可以通过平移和缩放来看网页的不同部分。


设置 Viewport

一个常用的针对移动网页优化过的页面的 viewport meta 标签大致如下:

  • width:控制 viewport 的大小,可以指定的一个值,如果 600,或者特殊的值,如 device-width 为设备的宽度(单位为缩放为 100% 时的 CSS 的像素)。
  • height:和 width 相对应,指定高度。
  • initial-scale:初始缩放比例,也即是当页面第一次 load 的时候缩放比例。
  • maximum-scale:允许用户缩放到的最大比例。
  • minimum-scale:允许用户缩放到的最小比例。
  • user-scalable:用户是否可以手动进行缩放(0或1)。

以下实例演示了使用viewport和没使用viewport在移动端上的效果:

代码如下:

<!DOCTPYE html>
<html lang="zh">
<head>
	<link rel="icon" href="beyond.jpg" type="image/x-icon"/>
	<meta charset="UTF-8">
	<meta name="author" content="beyond">
	<meta http-equiv="refresh" content="520">
	<meta name="description" content="免费零基础教程">
	<meta name="viewport" content="width=device-width, 
	initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0,user-scalable=0" />
	<meta name="keywords" content="HTML,CSS,JAVASCRIPT">
	<title>beyondの心中の动漫神作</title>
	<link rel="stylesheet" type="text/css" href="beyondbasestylewhite3.css">

	<!--[if lt IE 9]>
		<script src="//apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"></script>
	<![endif]-->

	<style type="text/css">
		body{
			font-size: 100%;
			/*background-image: url("sakura4.png");
			background-repeat: no-repeat;
			background-position: center center;*/
			/*声明margin和padding是个好习惯*/
			margin: 0;
			padding: 0;
		}
		/*让图片响应屏幕大小的改变*/
		img {
			max-width: 100%;
			height: auto;
		}
	</style>
</head>

<body>
		<h1 style="color:white;text-shadow:2px 2px 4px #000;letter-spacing:5px;" class="sgcontentcolor sgcenter">
			未 闻 花 名
		</h1>
		<img src="menma.png" alt="面码" width="600" height="600" />
		<p>
			在我们走过的季节里,路旁盛开的花朵也在不断变化,那个季节盛开的花是叫什么来着?轻轻摇曳着,一碰会微微刺痛,靠近一闻,隐约有股青涩的阳光的气息。那气息渐渐地淡去,我们也在慢慢长大。可是,那朵花一定还在某个地方盛开着……对,我们永远都会继续实现那朵花的愿望。
		</p>
		<p class="sgcontentcolor sgcenter" style="clear:left;">
			<b>注意:</b>图片会跟着窗口发生缩放
			
		</p>
		<!-- <a style="color:red;"></a> -->
		<footer id="copyright">
			<p style="font-size:14px;text-align:center;font-style:italic;">
			Copyright © <a id="author">2018</a> Powered by <a id="author">beyond</a>
			</p>		
		</footer>	
</body>
</html>

效果如下:



添加 viewport代码如上面所示:

如果你在平板电脑或手机上访问,可以直接点击查看效果。


相关文章

CSS教程:响应式 Web 设计




响应式 Web 设计 - 介绍


什么是响应式 Web 设计?

响应式 Web 设计让你的网页能在所有设备上有好显示。

响应式 Web 设计只使用 HTML 和 CSS。

响应式 Web 设计不是一个程序或Javascript脚本。


设计最好的用户体验

友好的用户体验是网页可以在任何设备上展示和操作,设备包括桌面系统设备,平板电脑,iPhone等手机等。

网页应该根据设备的大小自动调整内容。

桌面设备


平板设备


手机设备


页面的设计与开发根据用户行为以及设备环境(系统平台、屏幕尺寸、横竖屏等)进行相应的响应和调整称之为响应式 Web 设计。


响应式 Web 设计 - 网格视图


什么是网格视图?

很多网页都是基于网格设计的,这说明网页是按来布局的。

使用网格视图有助于我们设计网页。这让我们向网页添加元素变的更简单。

响应式网格视图通常是 12 列,宽度为100%,

在浏览器窗口大小调整时会自动伸缩

响应式网格视图



代码如下:asdf(难,完全看不懂!!!)

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<style>
* {
    box-sizing:border-box;
}
.class_div_wrapper {
	overflow:auto;
	position:relative;
	height:250px;
}
.class_div_content {
	width:8.33%;
	margin:0;
	xborder-left:1px solid grey;
    border-right:1px solid grey;
	height:100%;
	float:left;
	background-color:#84c754;
	background-color:#f1f1f1;	
}
</style>
</head>
<body>

<div style="position:absolute;opacity:0.9;width:auto;left:8px;right:10px;">
	<div class="gridcontainer">
		<div class="class_div_wrapper" style="height:90px;">
			<div class="class_div_content" style="width:100%;background:#9933cc;border-right-color:transparent;">
			</div>
		</div>
		<div class="class_div_wrapper" style="height:230px;">
			<div class="class_div_content" style="background-color:#ffffff;border:none;width:25%;padding-top:15px;">
				<div style="background-color:#33b5e5;border:none;width:100%;height:15%;margin-bottom:10px;"></div>
				<div style="background-color:#33b5e5;border:none;width:100%;height:15%;margin-bottom:10px;"></div>
				<div style="background-color:#33b5e5;border:none;width:100%;height:15%;margin-bottom:10px;"></div>
				<div style="background-color:#33b5e5;border:none;width:100%;height:15%;"></div>
			</div>
			<div class="class_div_content" style="background-color:#ffffff;border:none;"></div>
			<div class="class_div_content" style="background-color:#ffffff;border:none;"></div>
			<div class="class_div_content" style="background-color:#ffffff;border:none;"></div>
			<div class="class_div_content" style="background-color:#ffffff;border:none;"></div>
			<div class="class_div_content" style="background-color:#ffffff;border:none;"></div>
			<div class="class_div_content" style="background-color:#ffffff;border:none;"></div>

			<div class="class_div_content" style="background-color:#ffffff;border:none;width:25%;padding-top:15px;">
				<div style="background-color:#33b5e5;border:none;width:100%;height:92%;"></div>
			</div>
		</div>
		<div class="class_div_wrapper" style="height:50px;">
			<div class="class_div_content" style="width:100%;background:#0099cc;border-right-color:transparent;">
			</div>
		</div>

	</div>
</div>

<div class="gridcontainer" style="opacity:0.1;">
	<div class="class_div_wrapper" style="height:370px;">
		<div class="class_div_content" style="background-color:#ffffff;border-right:1px solid #000000;border-left:1px solid #000000;"></div>
		<div class="class_div_content" style="background-color:#ffffff;border-right:1px solid #000000;"></div>
		<div class="class_div_content" style="background-color:#ffffff;border-right:1px solid #000000;"></div>
		<div class="class_div_content" style="background-color:#ffffff;border-right:1px solid #000000;"></div>
		<div class="class_div_content" style="background-color:#ffffff;border-right:1px solid #000000;"></div>
		<div class="class_div_content" style="background-color:#ffffff;border-right:1px solid #000000;"></div>
		<div class="class_div_content" style="background-color:#ffffff;border-right:1px solid #000000;"></div>
		<div class="class_div_content" style="background-color:#ffffff;border-right:1px solid #000000;"></div>
		<div class="class_div_content" style="background-color:#ffffff;border-right:1px solid #000000;"></div>
		<div class="class_div_content" style="background-color:#ffffff;border-right:1px solid #000000;"></div>
		<div class="class_div_content" style="background-color:#ffffff;border-right:1px solid #000000;"></div>
		<div class="class_div_content" style="background-color:#ffffff;border-right:1px solid #000000;"></div>
	</div>
</div>
<p>重置浏览器窗口大小网格会自动伸缩。</p>
</body>
</html>


效果如下:







创建响应式网格视图

接下来我们来创建一个响应式网格视图。

首先确保所有 HTML 元素都有 box-sizing 属性且设置为 border-box

确保边距和边框包含在元素的宽度和高度间。

添加如下代码:

* {
    box-sizing: border-box;
}

查看更多 box-sizing 内容请点击:CSS3 box-sizing 属性 

以下实例演示了最最简单的响应式网页,包含两列:

代码如下:

<!DOCTPYE html>
<html lang="zh">
<head>
	<link rel="icon" href="beyond.jpg" type="image/x-icon"/>
	<meta charset="UTF-8">
	<meta name="author" content="beyond">
	<meta http-equiv="refresh" content="520">
	<meta name="description" content="免费零基础教程">
	<meta name="viewport" content="width=device-width, 
	initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0,user-scalable=0" />
	<meta name="keywords" content="HTML,CSS,JAVASCRIPT">
	<title>beyondの心中の动漫神作</title>
	<link rel="stylesheet" type="text/css" href="beyondbasestylewhite3.css">

	<!--[if lt IE 9]>
		<script src="//apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"></script>
	<![endif]-->

	<style type="text/css">
		body{
			font-size: 100%;
			/*background-image: url("sakura4.png");
			background-repeat: no-repeat;
			background-position: center center;*/
			/*声明margin和padding是个好习惯*/
			margin: 0;
			padding: 0;
		}
		/*响应式布局,必须加这一句CSS3*/
		* {
			box-sizing: border-box;
		}
		div.class_div_header {
			border: 1px solid red;
			padding: 15px;
		}
		div.class_div_menu {
			width: 25%;
			/*左浮动*/
			float: left;
			border:1px solid green;
		}
		div.class_div_main {
			width: 75%;
			/*左浮动*/
			float: left;
			padding: 15px;
			border:1px solid blue;
		}
	</style>
</head>

<body>
<div class="class_div_header">
	<h1 style="color:white;text-shadow:2px 2px 4px #000;letter-spacing:5px;" class="sgcontentcolor sgcenter">
			未 闻 花 名
	</h1>
</div>

<div class="class_div_menu">
	<ul>
		<li>首页</li>
		<li>APP</li>
		<li>民间偏方</li>
		<li>动漫</li>
	</ul>
</div>

<div class="class_div_main">
	<h1 style="color:white;text-shadow:2px 2px 4px #000;letter-spacing:5px;" class="sgcontentcolor sgcenter">
			未 闻 花 名
	</h1>
	<p>
			在我们走过的季节里,路旁盛开的花朵也在不断变化,那个季节盛开的花是叫什么来着?轻轻摇曳着,一碰会微微刺痛,靠近一闻,隐约有股青涩的阳光的气息。那气息渐渐地淡去,我们也在慢慢长大。可是,那朵花一定还在某个地方盛开着……对,我们永远都会继续实现那朵花的愿望。
	</p>
	<p class="sgcontentcolor sgcenter" style="clear:left;">
			<b>注意:</b>必须设置所有元素的box-sizing属性为border-box
			
	</p>
</div>
<footer id="copyright">
			<p style="font-size:14px;text-align:center;font-style:italic;">
			Copyright © <a id="author">2018</a> Powered by <a id="author">beyond</a>
			</p>		
</footer>	
		
		
		
			
</body>
</html>

效果如下:


核心代码:

.menu {
     width:  25%;
     float:  left;
}
.main {
     width:  75%;
     float:  left;
}

以上实例包含两列,左边menu占25%,右边main占75%


12 列的网格系统可以更好的控制响应式网页

首先我们可以计算每列的百分比: 100% / 12 列 = 8.33%。

在每列中指定 class, class="col-" 用于定义每列有几个 span ???Excuse Me???

代码如下:

<!DOCTPYE html>
<html lang="zh">
<head>
	<link rel="icon" href="beyond.jpg" type="image/x-icon"/>
	<meta charset="UTF-8">
	<meta name="author" content="beyond">
	<meta http-equiv="refresh" content="520">
	<meta name="description" content="免费零基础教程">
	<meta name="viewport" content="width=device-width, 
	initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0,user-scalable=0" />
	<meta name="keywords" content="HTML,CSS,JAVASCRIPT">
	<title>beyondの心中の动漫神作</title>
	<link rel="stylesheet" type="text/css" href="beyondbasestylewhite3.css">

	<!--[if lt IE 9]>
		<script src="//apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"></script>
	<![endif]-->

	<style type="text/css">
		body{
			font-size: 100%;
			/*background-image: url("sakura4.png");
			background-repeat: no-repeat;
			background-position: center center;*/
			/*声明margin和padding是个好习惯*/
			margin: 0;
			padding: 0;
		}
		/*响应式布局,必须加这一句CSS3*/
		* {
			box-sizing: border-box;
		}
		div.class_div_header {
			border: 1px solid red;
			padding: 15px;
		}
		/*这个是在它后面添加啥???空白文本???*/
		div.class_div_12row:after {
			content: "";
			clear: both;
			/*将啥转成了block块???*/
			display: block;
		}
		/*这个又是啥选择器???*/
		[class*="col-"] {
			float: left;
			padding: 15px;
			border:1px solid Teal;
		}
		.col-1 {width: 8.33%;}
		.col-2 {width: 16.66%;}
		.col-3 {width: 25%;}
		.col-4 {width: 33.33%;}
		.col-5 {width: 41.66%;}
		.col-6 {width: 50%;}
		.col-7 {width: 58.33%;}
		.col-8 {width: 66.66%;}
		.col-9 {width: 75%;}
		.col-10 {width: 83.33%;}
		.col-11 {width: 91.66%;}
		.col-12 {width: 100%;}
	</style>
</head>

<body>
<div class="class_div_header">
	<h1 style="color:white;text-shadow:2px 2px 4px #000;letter-spacing:5px;" class="sgcontentcolor sgcenter">
			未 闻 花 名
	</h1>
</div>

<div class="class_div_12row">
	<div class="col-3">
		<ul>
			<li>首页</li>
			<li>APP</li>
			<li>民间偏方</li>
			<li>动漫</li>
		</ul>
	</div>

	<div class="col-9">
		<h1 style="color:white;text-shadow:2px 2px 4px #000;letter-spacing:5px;" class="sgcontentcolor sgcenter">
				未 闻 花 名
		</h1>
		<p>
				在我们走过的季节里,路旁盛开的花朵也在不断变化,那个季节盛开的花是叫什么来着?轻轻摇曳着,一碰会微微刺痛,靠近一闻,隐约有股青涩的阳光的气息。那气息渐渐地淡去,我们也在慢慢长大。可是,那朵花一定还在某个地方盛开着……对,我们永远都会继续实现那朵花的愿望。
		</p>
		<p class="sgcontentcolor sgcenter" style="clear:left;">
				<b>注意:</b>必须设置所有元素的box-sizing属性为border-box
		</p>
	</div>
	<footer id="copyright">
				<p style="font-size:14px;text-align:center;font-style:italic;">
				Copyright © <a id="author">2018</a> Powered by <a id="author">beyond</a>
				</p>		
	</footer>	
</div>
			
</body>
</html>

效果如下:



CSS 核心通用代码:

.col-1 { width:  8.33%;}
.col-2 { width:  16.66%;}
.col-3 { width:  25%;}
.col-4 { width:  33.33%;}
.col-5 { width:  41.66%;}
.col-6 { width:  50%;}
.col-7 { width:  58.33%;}
.col-8 { width:  66.66%;}
.col-9 { width:  75%;}
.col-10 { width:  83.33%;}
.col-11 { width:  91.66%;}
.col-12 { width:  100%;}

所有的class含有值col-的列 向左浮动,间距(padding) 为 15px:

CSS:

[class*="col-"] {
     float:  left;
     padding:  15px;
     border:  1px solid red;
}

每一行使用 <div> 包裹。所有列数加起来应该为 12才对:

< div  class= "class_div_12row" >
   < div  class= "col-3" >... < /div >
   < div  class= "col-9" >... < /div >
< /div >

列中的行   为左浮动,并添加清除浮动:

CSS:

.div_class_12row:after {
     content:  "";
     clear:  both;
     display:  block;
}

我们可以添加一些样式和颜色,让其更好看:

完整代码如下:

<!DOCTPYE html>
<html lang="zh">
<head>
	<link rel="icon" href="beyond.jpg" type="image/x-icon"/>
	<meta charset="UTF-8">
	<meta name="author" content="beyond">
	<meta http-equiv="refresh" content="520">
	<meta name="description" content="免费零基础教程">
	<meta name="viewport" content="width=device-width, 
	initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0,user-scalable=0" />
	<meta name="keywords" content="HTML,CSS,JAVASCRIPT">
	<title>beyondの心中の动漫神作</title>
	<link rel="stylesheet" type="text/css" href="beyondbasestylewhite3.css">

	<!--[if lt IE 9]>
		<script src="//apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"></script>
	<![endif]-->

	<style type="text/css">

		body{
			font-size: 100%;
			/*background-image: url("sakura4.png");
			background-repeat: no-repeat;
			background-position: center center;*/
			/*声明margin和padding是个好习惯*/
			margin: 0;
			padding: 0;
		}
		/*响应式布局,必须加这一句CSS3*/
		* {
			box-sizing: border-box;
		}
		div.class_div_header {
			/*border: 1px solid red;*/
			padding: 15px;
		}
		/*这个是在它后面添加啥???空白文本???*/
		div.class_div_12row:after {
			content: "";
			clear: both;
			/*将啥转成了block块???*/
			display: block;
		}
		/*这个又是啥选择器???*/
		[class*="col-"] {
			float: left;
			padding: 15px;
			/*border:1px solid Teal;*/
		}
		.col-1 {width: 8.33%;}
		.col-2 {width: 16.66%;}
		.col-3 {width: 25%;}
		.col-4 {width: 33.33%;}
		.col-5 {width: 41.66%;}
		.col-6 {width: 50%;}
		.col-7 {width: 58.33%;}
		.col-8 {width: 66.66%;}
		.col-9 {width: 75%;}
		.col-10 {width: 83.33%;}
		.col-11 {width: 91.66%;}
		.col-12 {width: 100%;}

		/*美化一下页面样式*/
		html {
			font-family: "Lucida Sans",sans-serif;
		}
		div.class_div_header {
			background-color: #9933cc;
			color: #fff;
			padding: 15px;
		}
		div.class_div_menu ul {
			list-style-type: none;
			margin: 0;
			padding: 0;
		}
		div.class_div_menu li {
			padding: 8px;
			margin-bottom: 7px;
			background-color: #33b5e5;
			color: #fff;
			/*这个是什么鬼参数*/
			box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
		}
		div.class_div_menu li:hover {
			background-color: #0099cc;
		}
	</style>
</head>

<body>
<div class="class_div_header">
	<h1>光辉岁月</h1>
</div>

<div class="class_div_12row">
	<div class="col-3 class_div_menu">
		<ul>
			<li>首页</li>
			<li>APP</li>
			<li>民间偏方</li>
			<li>动漫</li>
		</ul>
	</div>

	<div class="col-9">
		<h1 style="color:white;text-shadow:2px 2px 4px #000;letter-spacing:5px;" class="sgcontentcolor sgcenter">
				未 闻 花 名
		</h1>
		<p>
				在我们走过的季节里,路旁盛开的花朵也在不断变化,那个季节盛开的花是叫什么来着?轻轻摇曳着,一碰会微微刺痛,靠近一闻,隐约有股青涩的阳光的气息。那气息渐渐地淡去,我们也在慢慢长大。可是,那朵花一定还在某个地方盛开着……对,我们永远都会继续实现那朵花的愿望。
		</p>
		<p class="sgcontentcolor sgcenter" style="clear:left;">
				<b>注意:</b>必须设置所有元素的box-sizing属性为border-box
		</p>
	</div>
	<footer id="copyright">
				<p style="font-size:14px;text-align:center;font-style:italic;">
				Copyright © <a id="author">2018</a> Powered by <a id="author">beyond</a>
				</p>		
	</footer>	
</div>
			
</body>
</html>

效果如下:



核心代码:

html {
     font-family:  "Lucida Sans", sans-serif;
}
.header {
     background-color:  #9933cc;
     color:  #ffffff;
     padding:  15px;
}
.menu ul {
     list-style-type:  none;
     margin:  0;
     padding:  0;
}
.menu li {
     padding:  8px;
     margin-bottom:  7px;
     background-color : #33b5e5;
     color:  #ffffff;
     box-shadow:  0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}
.menu li:hover {
     background-color:  #0099cc;
}



响应式 Web 设计 - 媒体查询


媒体(media)查询在 CSS3 上有介绍:CSS3 @media 查询

使用 @media 查询,你可以针对不同的媒体类型定义不同的样式:

演示代码中,如果浏览器窗口小于500px时,背景将变成浅蓝色

代码如下:

<!DOCTPYE html>
<html lang="zh">
<head>
	<link rel="icon" href="beyond.jpg" type="image/x-icon"/>
	<meta charset="UTF-8">
	<meta name="author" content="beyond">
	<meta http-equiv="refresh" content="520">
	<meta name="description" content="免费零基础教程">
	<meta name="viewport" content="width=device-width, 
	initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0,user-scalable=0" />
	<meta name="keywords" content="HTML,CSS,JAVASCRIPT">
	<title>beyondの心中の动漫神作</title>
	<link rel="stylesheet" type="text/css" href="beyondbasestylewhite3.css">

	<!--[if lt IE 9]>
		<script src="//apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"></script>
	<![endif]-->

	<style type="text/css">

		body{
			font-size: 100%;
			/*background-image: url("sakura4.png");
			background-repeat: no-repeat;
			background-position: center center;*/
			/*声明margin和padding是个好习惯*/
			margin: 0;
			padding: 0;
		}
		body {
			background-color: lightgreen;
		}
		/*媒体查询 当窗口小于500px时,自动变色*/
		@media only screen and (max-width: 500px) {
			body {
				background-color: lightblue;
			}
		}
	</style>
</head>

<body>

		<h1 style="color:white;text-shadow:2px 2px 4px #000;letter-spacing:5px;" class="sgcontentcolor sgcenter">
				未 闻 花 名
		</h1>
		<p>
				在我们走过的季节里,路旁盛开的花朵也在不断变化,那个季节盛开的花是叫什么来着?轻轻摇曳着,一碰会微微刺痛,靠近一闻,隐约有股青涩的阳光的气息。那气息渐渐地淡去,我们也在慢慢长大。可是,那朵花一定还在某个地方盛开着……对,我们永远都会继续实现那朵花的愿望。
		</p>
		<p class="sgcontentcolor sgcenter" style="clear:left;">
				<b>注意:</b>媒体查询可根据窗口大小,动态设置样式
		</p>
	
	<footer id="copyright">
				<p style="font-size:14px;text-align:center;font-style:italic;">
				Copyright © <a id="author">2018</a> Powered by <a id="author">beyond</a>
				</p>		
	</footer>	

			
</body>
</html>

效果如下:


核心代码:

如果浏览器窗口小于 500px, 背景将变为浅蓝色:

@media only screen and (max-width: 500px) {
    body {
         background-color:  lightblue;
    }
}

添加断点

在先前的教程中我们使用 行和列 来制作网页,它是响应式的,但在小屏幕上并不能友好的展示。

媒体查询可以帮我们解决这个问题。

我们可以在设计稿的中间添加断点,不同的断点有不同的效果。

桌面设备

手机设备

使用媒体查询在 768px的宽度处 添加 断点:

即当屏幕小于768px的时候,每一列全宽为100%

当屏幕大于768px的时候,按桌面的效果显示

完整代码如下:

<!DOCTPYE html>
<html lang="zh">
<head>
	<link rel="icon" href="beyond.jpg" type="image/x-icon"/>
	<meta charset="UTF-8">
	<meta name="author" content="beyond">
	<meta http-equiv="refresh" content="520">
	<meta name="description" content="免费零基础教程">
	<meta name="viewport" content="width=device-width, 
	initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0,user-scalable=0" />
	<meta name="keywords" content="HTML,CSS,JAVASCRIPT">
	<title>beyondの心中の动漫神作</title>
	<link rel="stylesheet" type="text/css" href="beyondbasestylewhite3.css">

	<!--[if lt IE 9]>
		<script src="//apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"></script>
	<![endif]-->

	<style type="text/css">

		body{
			font-size: 100%;
			/*background-image: url("sakura4.png");
			background-repeat: no-repeat;
			background-position: center center;*/
			/*声明margin和padding是个好习惯*/
			margin: 0;
			padding: 0;
		}
		/*响应式布局,必须加这一句CSS3*/
		* {
			box-sizing: border-box;
		}
		div.class_div_header {
			/*border: 1px solid red;*/
			padding: 15px;
		}
		/*这个是在它后面添加啥???空白文本???*/
		div.class_div_12row:after {
			content: "";
			clear: both;
			/*将啥转成了block块???*/
			display: block;
		}
		/*这个又是啥选择器???*/
		[class*="col-"] {
			float: left;
			padding: 15px;
			/*border:1px solid Teal;*/
		}
		.col-1 {width: 8.33%;}
		.col-2 {width: 16.66%;}
		.col-3 {width: 25%;}
		.col-4 {width: 33.33%;}
		.col-5 {width: 41.66%;}
		.col-6 {width: 50%;}
		.col-7 {width: 58.33%;}
		.col-8 {width: 66.66%;}
		.col-9 {width: 75%;}
		.col-10 {width: 83.33%;}
		.col-11 {width: 91.66%;}
		.col-12 {width: 100%;}

		/*美化一下页面样式*/
		html {
			font-family: "Lucida Sans",sans-serif;
		}
		div.class_div_header {
			background-color: #9933cc;
			color: #fff;
			padding: 15px;
		}
		div.class_div_menu ul {
			list-style-type: none;
			margin: 0;
			padding: 0;
		}
		div.class_div_menu li {
			padding: 8px;
			margin-bottom: 7px;
			background-color: #33b5e5;
			color: #fff;
			/*这个是什么鬼参数*/
			box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
		}
		div.class_div_menu li:hover {
			background-color: #0099cc;
		}
		@media only screen and (max-width: 640px) {
			/*手机上每一列全宽100%*/
			[class*="col-"] {
				width: 100%;
			}
		}
	</style>
</head>

<body>
<div class="class_div_header">
	<h1>光辉岁月</h1>
</div>

<div class="class_div_12row">
	<div class="col-3 class_div_menu">
		<ul>
			<li>首页</li>
			<li>APP</li>
			<li>民间偏方</li>
			<li>动漫</li>
		</ul>
	</div>

	<div class="col-9">
		<h1 style="color:white;text-shadow:2px 2px 4px #000;letter-spacing:5px;" class="sgcontentcolor sgcenter">
				未 闻 花 名
		</h1>
		<p>
				在我们走过的季节里,路旁盛开的花朵也在不断变化,那个季节盛开的花是叫什么来着?轻轻摇曳着,一碰会微微刺痛,靠近一闻,隐约有股青涩的阳光的气息。那气息渐渐地淡去,我们也在慢慢长大。可是,那朵花一定还在某个地方盛开着……对,我们永远都会继续实现那朵花的愿望。
		</p>
		<p class="sgcontentcolor sgcenter" style="clear:left;">
				<b>注意:</b>必须设置所有元素的box-sizing属性为border-box
				<br/>
				手机上屏幕宽小于等于640时,每列全宽100%
		</p>
	</div>
	<footer id="copyright">
				<p style="font-size:14px;text-align:center;font-style:italic;">
				Copyright © <a id="author">2018</a> Powered by <a id="author">beyond</a>
				</p>		
	</footer>	
</div>
			
</body>
</html>

效果如下:


核心代码如下:  iPhone 5S 是640 X 1136

当屏幕 (浏览器窗口) 小于 640px, 每一列的宽度是 100%:

/* For desktop: */
.col-1 { width:  8.33%;}
.col-2 { width:  16.66%;}
.col-3 { width:  25%;}
.col-4 { width:  33.33%;}
.col-5 { width:  41.66%;}
.col-6 { width:  50%;}
.col-7 { width:  58.33%;}
.col-8 { width:  66.66%;}
.col-9 { width:  75%;}
.col-10 { width:  83.33%;}
.col-11 { width:  91.66%;}
.col-12 { width:  100%;}

@media only screen and (max-width: 640px) {
    /* For mobile phones: */
    [class*="col-"] {
        width: 100%;
    }
}

为移动端优先设计 

默认样式全是为了移动端设计的, 只有在屏幕大于640的时候,才用桌面样式

移动端优先意味着在设计桌面和其他设备时优先考虑移动端的设计。

这就意味着我们必须对默认的 CSS 做一些改变。

我们对屏幕小于 768px时的默认样式 进行样式修改,

同样在发现屏幕宽度大于 768px 时也需要修改一下特殊的样式。

以下是移动端优先实例:

/* 为移动端设计: */
[class*="col-"] {
     width:  100%;
}
@media only screen and (min-width: 768px) {
    /* For desktop: */
    .col-1 {width: 8.33%;}
    .col-2 {width: 16.66%;}
    .col-3 {width: 25%;}
    .col-4 {width: 33.33%;}
    .col-5 {width: 41.66%;}
    .col-6 {width: 50%;}
    .col-7 {width: 58.33%;}
    .col-8 {width: 66.66%;}
    .col-9 {width: 75%;}
    .col-10 {width: 83.33%;}
    .col-11 {width: 91.66%;}
    .col-12 {width: 100%;}
}

其他断点

你可以根据自己的需要添加断点。

我们同样可以为平板设备 移动手机设备设置断点。

桌面设备

平板设备

手机设备

在屏幕为 660px 时添加媒体查询,并设置ipad屏幕的新的样式(屏幕大于600px但小于768px)

完整代码如下: (牛X)

<!DOCTPYE html>
<html lang="zh">
<head>
	<link rel="icon" href="beyond.jpg" type="image/x-icon"/>
	<meta charset="UTF-8">
	<meta name="author" content="beyond">
	<meta http-equiv="refresh" content="520">
	<meta name="description" content="免费零基础教程">
	<meta name="viewport" content="width=device-width, 
	initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0,user-scalable=0" />
	<meta name="keywords" content="HTML,CSS,JAVASCRIPT">
	<title>beyondの心中の动漫神作</title>
	<link rel="stylesheet" type="text/css" href="beyondbasestylewhite3.css">

	<!--[if lt IE 9]>
		<script src="//apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"></script>
	<![endif]-->

	<style type="text/css">

		body{
			font-size: 100%;
			/*background-image: url("sakura4.png");
			background-repeat: no-repeat;
			background-position: center center;*/
			/*声明margin和padding是个好习惯*/
			margin: 0;
			padding: 0;
		}
		/*响应式布局,必须加这一句CSS3*/
		* {
			box-sizing: border-box;
		}

		/*这个是在它后面添加啥???空白文本???*/
		div.class_div_12row:after {
			content: "";
			clear: both;
			/*将啥转成了block块???*/
			display: block;
		}
		

		/*美化一下页面样式*/
		html {
			font-family: "Lucida Sans",sans-serif;
		}
		div.class_div_header {
			background-color: #9933cc;
			color: #fff;
			padding: 2px;
		}
		div.class_div_menu ul {
			list-style-type: none;
			margin: 0;
			padding: 0;
		}
		div.class_div_menu li {
			padding: 8px;
			margin-bottom: 7px;
			background-color: #33b5e5;
			color: #fff;
			/*这个是什么鬼参数*/
			box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
		}
		div.class_div_menu li:hover {
			background-color: #0099cc;
		}

		/*新增的右侧边栏*/
		div.class_div_rightaside {
			background-color: #33b5e5;
			padding: 5px;
			color: #fff;
			text-align: center;
			font-size: 14px;
			/*各个参数是什么鬼???*/
			box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
		}
		/*新增的底部栏*/
		div.class_div_footer {
			background-color: rgba(17,134,193,0.2);
			/*color: #fff;*/
			text-align: center;
			font-size: 12px;
			padding: 3px;
		}

		/*这个又是啥选择器???
		  默认是移动优先设计
		  手机上每一列全宽100%*/
		[class*="col-"] {
			width: 100%;
		}
		/*全部左浮动*/
		[class*="col-"] {
			float: left;
			padding: 2px;
		}
		@media only screen and (min-width: 640px) {
			/*大于640时,也就是来到了平板屏幕的世界*/
			.col-m-1 {width: 8.33%;}
			.col-m-2 {width: 16.66%;}
		    .col-m-3 {width: 25%;}
		    .col-m-4 {width: 33.33%;}
		    .col-m-5 {width: 41.66%;}
		    .col-m-6 {width: 50%;}
		    .col-m-7 {width: 58.33%;}
		    .col-m-8 {width: 66.66%;}
		    .col-m-9 {width: 75%;}
		    .col-m-10 {width: 83.33%;}
		    .col-m-11 {width: 91.66%;}
		    .col-m-12 {width: 100%;}
		}
		@media only screen and (min-width: 768px) {
			/*大于768时,也就是来到了电脑屏幕的世界*/
			.col-1 {width: 8.33%;}
			.col-2 {width: 16.66%;}
			.col-3 {width: 25%;}
			.col-4 {width: 33.33%;}
			.col-5 {width: 41.66%;}
			.col-6 {width: 50%;}
			.col-7 {width: 58.33%;}
			.col-8 {width: 66.66%;}
			.col-9 {width: 75%;}
			.col-10 {width: 83.33%;}
			.col-11 {width: 91.66%;}
			.col-12 {width: 100%;}
		}
	</style>
</head>

<body>
<div class="class_div_header">
	<h1>光辉岁月</h1>
</div>

<div class="class_div_12row">
	<div class="col-3 col-m-3 class_div_menu">
		<ul>
			<li>首页</li>
			<li>APP</li>
			<li>民间偏方</li>
			<li>动漫</li>
		</ul>
	</div>

	<div class="col-6 col-m-9">
		<h1 style="color:white;text-shadow:2px 2px 4px #000;letter-spacing:5px;" class="sgcontentcolor sgcenter">
				未 闻 花 名
		</h1>
		<p>
				在我们走过的季节里,路旁盛开的花朵也在不断变化,那个季节盛开的花是叫什么来着?轻轻摇曳着,一碰会微微刺痛,靠近一闻,隐约有股青涩的阳光的气息。那气息渐渐地淡去,我们也在慢慢长大。可是,那朵花一定还在某个地方盛开着……对,我们永远都会继续实现那朵花的愿望。
		</p>
	</div>

	<div class="col-3 col-m-12">
		<div class="class_div_rightaside">
			<h2>龙与虎</h2>
			<p>讲述的是逢坂大河与高须龙儿之间的...</p>
			<h2>轻音少女</h2>
			<p>号称强国源泉,第一次发现没有男主的动漫也可以这么好看!</p>
		</div>
	</div>
	
</div>

<div class="class_div_footer">
	<footer id="copyright">
				<p style="font-size:14px;text-align:center;font-style:italic;">
				Copyright © <a id="author">2018</a> Powered by <a id="author">beyond</a>
				</p>		
	</footer>	
</div>
			
</body>
</html>

效果如下:


核心代码如下:

注意两组类样式是相同的,但名称不同 (col- 和 col-m-):

/* For mobile phones: */
[class*="col-"] {
     width:  100%;
}
@media only screen and (min-width: 600px) {
    /* For tablets: */
    .col-m-1 {width: 8.33%;}
    .col-m-2 {width: 16.66%;}
    .col-m-3 {width: 25%;}
    .col-m-4 {width: 33.33%;}
    .col-m-5 {width: 41.66%;}
    .col-m-6 {width: 50%;}
    .col-m-7 {width: 58.33%;}
    .col-m-8 {width: 66.66%;}
    .col-m-9 {width: 75%;}
    .col-m-10 {width: 83.33%;}
    .col-m-11 {width: 91.66%;}
    .col-m-12 {width: 100%;}
}
@media only screen and (min-width: 768px) {
    /* For desktop: */
    .col-1 {width: 8.33%;}
    .col-2 {width: 16.66%;}
    .col-3 {width: 25%;}
    .col-4 {width: 33.33%;}
    .col-5 {width: 41.66%;}
    .col-6 {width: 50%;}
    .col-7 {width: 58.33%;}
    .col-8 {width: 66.66%;}
    .col-9 {width: 75%;}
    .col-10 {width: 83.33%;}
    .col-11 {width: 91.66%;}
    .col-12 {width: 100%;}
}

以上代码看起来很多余,但是他可以根据屏幕大小自动设置不同的样式,所以还是非常必要的。

HTML 实例

默认是手机设备:全部跨100% 即12列

针对桌面设备特殊定制:

第一和第三部分跨越 3 列。中间部分跨域 6 列。

针对平板设备特殊定制:

第一跨域 3列,第二部分跨越 9 列,第三部分跨域 12 列:

< div  class= "row" >
< div  class= "col-3 col-m-3" >... < /div >
< div  class= "col-6 col-m-9" >... < /div >
< div  class= "col-3 col-m-12" >... < /div >
< /div >

方向:横屏/竖屏

结合CSS媒体查询,可以创建适应不同设备的方向(横屏landscape、竖屏portrait等)的布局:

完整代码如下:

<!DOCTPYE html>
<html lang="zh">
<head>
	<link rel="icon" href="beyond.jpg" type="image/x-icon"/>
	<meta charset="UTF-8">
	<meta name="author" content="beyond">
	<meta http-equiv="refresh" content="520">
	<meta name="description" content="免费零基础教程">
	<meta name="viewport" content="width=device-width, 
	initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0,user-scalable=0" />
	<meta name="keywords" content="HTML,CSS,JAVASCRIPT">
	<title>beyondの心中の动漫神作</title>
	<link rel="stylesheet" type="text/css" href="beyondbasestylewhite3.css">

	<!--[if lt IE 9]>
		<script src="//apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"></script>
	<![endif]-->

	<style type="text/css">

		body{
			font-size: 100%;
			/*background-image: url("sakura4.png");
			background-repeat: no-repeat;
			background-position: center center;*/
			/*声明margin和padding是个好习惯*/
			margin: 0;
			padding: 0;
		}
		body {
			background-color: lightgreen;
		}
		/*横屏时,背景色变浅蓝*/
		@media only screen and (position: landscape) {
			body {
				background-color: lightblue;
			}
		}
		
	</style>
</head>

<body>
		<h1 style="color:white;text-shadow:2px 2px 4px #000;letter-spacing:5px;" class="sgcontentcolor sgcenter">
				未 闻 花 名
		</h1>
		<p>
				在我们走过的季节里,路旁盛开的花朵也在不断变化,那个季节盛开的花是叫什么来着?轻轻摇曳着,一碰会微微刺痛,靠近一闻,隐约有股青涩的阳光的气息。那气息渐渐地淡去,我们也在慢慢长大。可是,那朵花一定还在某个地方盛开着……对,我们永远都会继续实现那朵花的愿望。
		</p>
	
		<p class="sgcontentcolor sgcenter" style="clear:left;">
				<b>注意:</b>横屏时,背景色会变浅蓝喔~
		</p>

	<footer id="copyright">
				<p style="font-size:14px;text-align:center;font-style:italic;">
				Copyright © <a id="author">2018</a> Powered by <a id="author">beyond</a>
				</p>		
	</footer>	

			
</body>
</html>

效果如下: (暂时无法演示,下次补上)



语法:

orientation:portrait | landscape
  • portrait:指定输出设备中的页面可见区域高度大于或等于宽度
  • landscape: 除portrait值情况外,都是landscape

核心代码:

如果是横屏背景将是浅蓝色:

@media only screen and (orientation: landscape) {
    body {
         background-color:  lightblue;
    }
}

响应式 Web 设计 - 图片


使用 width 属性

如果 width 属性设置为 100%,图片会根据上下范围实现响应式功能

注意: 图片会放大,超过原来的大小,如果没有height:auto;约束的话,图片会变形

代码如下:

<!DOCTPYE html>
<html lang="zh">
<head>
	<link rel="icon" href="beyond.jpg" type="image/x-icon"/>
	<meta charset="UTF-8">
	<meta name="author" content="beyond">
	<meta http-equiv="refresh" content="520">
	<meta name="description" content="免费零基础教程">
	<meta name="viewport" content="width=device-width, 
	initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0,user-scalable=0" />
	<meta name="keywords" content="HTML,CSS,JAVASCRIPT">
	<title>beyondの心中の动漫神作</title>
	<link rel="stylesheet" type="text/css" href="beyondbasestylewhite3.css">

	<!--[if lt IE 9]>
		<script src="//apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"></script>
	<![endif]-->

	<style type="text/css">

		body{
			font-size: 100%;
			/*background-image: url("sakura4.png");
			background-repeat: no-repeat;
			background-position: center center;*/
			/*声明margin和padding是个好习惯*/
			margin: 0;
			padding: 0;
		}
		
		/*调整窗口,width:100%,图片也会跟着放大
		并且可以超过自身的原始大小*/
		img {
			width: 100%;
			/*不加上这个高度约束的话,图片会变形*/
			height: auto;
		}
	</style>
</head>

<body>
		<h1 style="color:white;text-shadow:2px 2px 4px #000;letter-spacing:5px;" class="sgcontentcolor sgcenter">
				未 闻 花 名
		</h1>
		<img src="sakura.png" width="300" height="300" />
	
		<p class="sgcontentcolor sgcenter" style="clear:left;">
				<b>注意:</b>调整窗口,width:100%,图片也会跟着放大<br/>
				并且可以超过自身的原始大小
		</p>

	<footer id="copyright">
				<p style="font-size:14px;text-align:center;font-style:italic;">
				Copyright © <a id="author">2018</a> Powered by <a id="author">beyond</a>
				</p>		
	</footer>	

			
</body>
</html>

效果如下:



核心代码:

img 
     width:  100%; 
     height:  auto; 
}

注意在以上实例中,图片会变比它的原始图片还。我们可以使用 max-width 属性很好的解决这个问题。


使用 max-width 属性

如果 max-width 属性设置为 100%, 图片永远不会大于其原始大小

效果如下:


核心代码:

img 
     max-width:  100%; 
     height:  auto; 
}

提示:关于max-width属性的更多内容,请参考本站CSS参考手册中的CSS max-width属性部分。


给html_282.html这个响应式网页中添加个图片

完整代码如下:

<!DOCTPYE html>
<html lang="zh">
<head>
	<link rel="icon" href="beyond.jpg" type="image/x-icon"/>
	<meta charset="UTF-8">
	<meta name="author" content="beyond">
	<meta http-equiv="refresh" content="520">
	<meta name="description" content="免费零基础教程">
	<meta name="viewport" content="width=device-width, 
	initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0,user-scalable=0" />
	<meta name="keywords" content="HTML,CSS,JAVASCRIPT">
	<title>beyondの心中の动漫神作</title>
	<link rel="stylesheet" type="text/css" href="beyondbasestylewhite3.css">

	<!--[if lt IE 9]>
		<script src="//apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"></script>
	<![endif]-->

	<style type="text/css">

		body{
			font-size: 100%;
			/*background-image: url("sakura4.png");
			background-repeat: no-repeat;
			background-position: center center;*/
			/*声明margin和padding是个好习惯*/
			margin: 0;
			padding: 0;
		}
		/*响应式布局,必须加这一句CSS3*/
		* {
			box-sizing: border-box;
		}

		/*这个是在它后面添加啥???空白文本???*/
		div.class_div_12row:after {
			content: "";
			clear: both;
			/*将啥转成了block块???*/
			display: block;
		}
		

		/*美化一下页面样式*/
		html {
			font-family: "Lucida Sans",sans-serif;
		}
		div.class_div_header {
			background-color: #9933cc;
			color: #fff;
			padding: 2px;
		}
		div.class_div_menu ul {
			list-style-type: none;
			margin: 0;
			padding: 0;
		}
		div.class_div_menu li {
			padding: 8px;
			margin-bottom: 7px;
			background-color: #33b5e5;
			color: #fff;
			/*这个是什么鬼参数*/
			box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
		}
		div.class_div_menu li:hover {
			background-color: #0099cc;
		}

		/*新增的右侧边栏*/
		div.class_div_rightaside {
			background-color: #33b5e5;
			padding: 5px;
			color: #fff;
			text-align: center;
			font-size: 14px;
			/*各个参数是什么鬼???*/
			box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
		}
		/*新增的底部栏*/
		div.class_div_footer {
			background-color: rgba(17,134,193,0.2);
			/*color: #fff;*/
			text-align: center;
			font-size: 12px;
			padding: 3px;
		}

		/*这个又是啥选择器???
		  默认是移动优先设计
		  手机上每一列全宽100%*/
		[class*="col-"] {
			width: 100%;
		}
		/*全部左浮动*/
		[class*="col-"] {
			float: left;
			padding: 2px;
		}
		@media only screen and (min-width: 640px) {
			/*大于640时,也就是来到了平板屏幕的世界*/
			.col-m-1 {width: 8.33%;}
			.col-m-2 {width: 16.66%;}
		    .col-m-3 {width: 25%;}
		    .col-m-4 {width: 33.33%;}
		    .col-m-5 {width: 41.66%;}
		    .col-m-6 {width: 50%;}
		    .col-m-7 {width: 58.33%;}
		    .col-m-8 {width: 66.66%;}
		    .col-m-9 {width: 75%;}
		    .col-m-10 {width: 83.33%;}
		    .col-m-11 {width: 91.66%;}
		    .col-m-12 {width: 100%;}
		}
		@media only screen and (min-width: 768px) {
			/*大于768时,也就是来到了电脑屏幕的世界*/
			.col-1 {width: 8.33%;}
			.col-2 {width: 16.66%;}
			.col-3 {width: 25%;}
			.col-4 {width: 33.33%;}
			.col-5 {width: 41.66%;}
			.col-6 {width: 50%;}
			.col-7 {width: 58.33%;}
			.col-8 {width: 66.66%;}
			.col-9 {width: 75%;}
			.col-10 {width: 83.33%;}
			.col-11 {width: 91.66%;}
			.col-12 {width: 100%;}
		}

		/*新增图片*/
		img {
			width: 100%;
			height: auto;
		}
	</style>
</head>

<body>
<div class="class_div_header">
	<h1>光辉岁月</h1>
</div>

<div class="class_div_12row">
	<div class="col-3 col-m-3 class_div_menu">
		<ul>
			<li>首页</li>
			<li>APP</li>
			<li>民间偏方</li>
			<li>动漫</li>
		</ul>
	</div>

	<div class="col-6 col-m-9">
		<h1 style="color:white;text-shadow:2px 2px 4px #000;letter-spacing:5px;" class="sgcontentcolor sgcenter">
				未 闻 花 名
		</h1>
		<p>
				在我们走过的季节里,路旁盛开的花朵也在不断变化,那个季节盛开的花是叫什么来着?轻轻摇曳着,一碰会微微刺痛,靠近一闻,隐约有股青涩的阳光的气息。那气息渐渐地淡去,我们也在慢慢长大。可是,那朵花一定还在某个地方盛开着……对,我们永远都会继续实现那朵花的愿望。
		</p>
		<img src="menma.png" width="300" height="300" />
	</div>

	<div class="col-3 col-m-12">
		<div class="class_div_rightaside">
			<h2>龙与虎</h2>
			<p>讲述的是逢坂大河与高须龙儿之间的...</p>
			<h2>轻音少女</h2>
			<p>号称强国源泉,第一次发现没有男主的动漫也可以这么好看!</p>
		</div>
	</div>
	
</div>

<div class="class_div_footer">
	<footer id="copyright">
				<p style="font-size:14px;text-align:center;font-style:italic;">
				Copyright © <a id="author">2018</a> Powered by <a id="author">beyond</a>
				</p>		
	</footer>	
</div>
			
</body>
</html>

效果如下:






核心代码:

img 
     width:  100%; 
     height:  auto; 
}

背景图片 background-size属性

背景图片也可以响应调整大小或缩放喔~

以下是三个不同的方法:

1. 如果 background-size 属性设置为 "contain", 背景图片将按比例自适应内容区域。

图片保持其比例不变,不会变形,会填充满一个方向,另一个方向会有留白

类似于iOS中的aspect-fit

代码如下:

<!DOCTPYE html>
<html lang="zh">
<head>
	<link rel="icon" href="beyond.jpg" type="image/x-icon"/>
	<meta charset="UTF-8">
	<meta name="author" content="beyond">
	<meta http-equiv="refresh" content="520">
	<meta name="description" content="免费零基础教程">
	<meta name="viewport" content="width=device-width, 
	initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0,user-scalable=0" />
	<meta name="keywords" content="HTML,CSS,JAVASCRIPT">
	<title>beyondの心中の动漫神作</title>
	<link rel="stylesheet" type="text/css" href="beyondbasestylewhite3.css">

	<!--[if lt IE 9]>
		<script src="//apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"></script>
	<![endif]-->

	<style type="text/css">

		body{
			font-size: 100%;
			/*background-image: url("sakura4.png");
			background-repeat: no-repeat;
			background-position: center center;*/
			/*声明margin和padding是个好习惯*/
			margin: 0;
			padding: 0;
		}
		
		div {
			width: 100%;
			height: 400px;
			background-image: url("menma.png");
			background-repeat: no-repeat;
			/*核心代码,background-size的4种样式之一:contain
			  不会变形,会有一边填充满,另一边留白*/
			background-size: contain;
			border:1px solid red;
		}
	</style>
</head>

<body>
		<h1 style="color:white;text-shadow:2px 2px 4px #000;letter-spacing:5px;" class="sgcontentcolor sgcenter">
				未 闻 花 名
		</h1>
		<div>
			
		</div>
	
		<p class="sgcontentcolor sgcenter" style="clear:left;">
				<b>注意:</b>调整窗口,background-size的4种样式之一:contain<br/>
			  不会变形,会有一边填充满,另一边留白
		</p>

	<footer id="copyright">
				<p style="font-size:14px;text-align:center;font-style:italic;">
				Copyright © <a id="author">2018</a> Powered by <a id="author">beyond</a>
				</p>		
	</footer>	

			
</body>
</html>

效果如下:



这是 CSS 代码:

核心代码:

div 
     width:  100%; 
     height:  400px; 
     background-image:  url('menma.png'); 
     background-repeat:  no-repeat; 
     background-size:  contain; 
     border:  1px solid red; 
}

2. 如果 background-size 属性设置为 "100% 100%" ,背景图片将延展覆盖整个区域:

如果background-size设置为宽100% 高100%,那么显然图片会完全拉伸并铺满div

类似于iOS中的scale-fill

效果如下:



核心代码:

这是 CSS 代码:

div 
     width:  100%; 
     height:  400px; 
     background-image:  url('menma.jpg'); 
     background-size:  100% 100%; 
     border:  1px solid red; 
}

3. 如果 background-size 属性设置为 "cover",则会把背景图像等比例放大

以使背景图像完全覆盖填充div区域,因此一部分的图片像素就不在div里了。


注意该属性保持了图片的比例因此 背景图像的某些部分无法显示在背景定位区域中:

效果如下:


这是 CSS 代码:

核心代码:

div 
     width:  100%; 
     height:  400px; 
     background-image:  url('img_flowers.jpg'); 
     background-size:  cover; 
     border:  1px solid red; 
}

不同设备显示不同图片

大尺寸图片可以显示在大屏幕上,但在小屏幕上却不能很好显示。

我们没有必要在小屏幕上去加载大图片,这样很影响加载速度。

所以我们又可以使用媒体查询了,根据不同的设备显示不同的图片。

以下大图片和小图片将显示在不同设备上:

代码如下:

<!DOCTPYE html>
<html lang="zh">
<head>
	<link rel="icon" href="beyond.jpg" type="image/x-icon"/>
	<meta charset="UTF-8">
	<meta name="author" content="beyond">
	<meta http-equiv="refresh" content="520">
	<meta name="description" content="免费零基础教程">
	<meta name="viewport" content="width=device-width, 
	initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0,user-scalable=0" />
	<meta name="keywords" content="HTML,CSS,JAVASCRIPT">
	<title>beyondの心中の动漫神作</title>
	<link rel="stylesheet" type="text/css" href="beyondbasestylewhite3.css">

	<!--[if lt IE 9]>
		<script src="//apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"></script>
	<![endif]-->

	<style type="text/css">

		body{
			font-size: 100%;
			/*background-image: url("sakura4.png");
			background-repeat: no-repeat;
			background-position: center center;*/
			/*声明margin和padding是个好习惯*/
			margin: 0;
			padding: 0;

			/*小窗口默认显示小图片*/
			background-image: url("sakura4.png");
		}
		/*大窗口时,显示大图*/
		@media only screen and (min-width: 640px) {
			body {
				background-image: url('menma.png');
			}
		}
		
		
	</style>
</head>

<body>
		<h1 style="color:white;text-shadow:2px 2px 4px #000;letter-spacing:5px;" class="sgcontentcolor sgcenter">
				未 闻 花 名
		</h1>
		
	
		<p class="sgcontentcolor sgcenter" style="clear:left;">
				<b>注意:</b>调整窗口,小窗口显示小图片,大窗口显示大图片
		</p>

	<footer id="copyright">
				<p style="font-size:14px;text-align:center;font-style:italic;">
				Copyright © <a id="author">2018</a> Powered by <a id="author">beyond</a>
				</p>		
	</footer>	

			
</body>
</html>

效果如下:



   

核心代码:

/* For width smaller than 400px: */ 
body 
     background-image:  url('img_smallflower.jpg'); 


/* For width 400px and larger: */ 
@media only screen and (min-width: 400px) 
    body 
         background-image:  url('img_bigflowers.jpg'); 
    } 
}

你可以使用媒体查询的 min-device-width 替代 min-width 属性,

它将检测的是设备宽度而不是浏览器宽度。

浏览器大小重置时,图片大小不会改变。

核心代码:

/* 设备小于 400px: */ 
body 
     background-image:  url('img_smallflower.jpg'); 


/* 设备大于 400px (也等于): */ 
@media only screen and (min-device-width: 400px) 
    body 
         background-image:  url('img_bigflowers.jpg'); 
    } 
}

HTML5 <picture元素

HTML5 的 <picture>元素可以设置多张图片。

< picture

元素类似于<video> 和 <audio> 元素。可以设备不同的资源,第一个设置的资源为首选使用的:

代码如下:

<!DOCTPYE html>
<html lang="zh">
<head>
	<link rel="icon" href="beyond.jpg" type="image/x-icon"/>
	<meta charset="UTF-8">
	<meta name="author" content="beyond">
	<meta http-equiv="refresh" content="520">
	<meta name="description" content="免费零基础教程">
	<meta name="viewport" content="width=device-width, 
	initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0,user-scalable=0" />
	<meta name="keywords" content="HTML,CSS,JAVASCRIPT">
	<title>beyondの心中の动漫神作</title>
	<link rel="stylesheet" type="text/css" href="beyondbasestylewhite3.css">

	<!--[if lt IE 9]>
		<script src="//apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"></script>
	<![endif]-->

	<style type="text/css">

		body{
			font-size: 100%;
			/*background-image: url("sakura4.png");
			background-repeat: no-repeat;
			background-position: center center;*/
			/*声明margin和padding是个好习惯*/
			margin: 0;
			padding: 0;
		}

		
		
	</style>
</head>

<body>
		<h1 style="color:white;text-shadow:2px 2px 4px #000;letter-spacing:5px;" class="sgcontentcolor sgcenter">
				未 闻 花 名
		</h1>
		
		<picture>
			<source srcset="sakura4.png" media="(max-width:640px)"/>
			<source srcset="menma.png"/>
			<img src="menma.png" alt="面码" style="width:auto;">
		</picture>
	
		<p class="sgcontentcolor sgcenter" style="clear:left;">
				<b>注意:</b>调整窗口,小窗口显示小图片,大窗口显示大图片
		</p>

	<footer id="copyright">
				<p style="font-size:14px;text-align:center;font-style:italic;">
				Copyright © <a id="author">2018</a> Powered by <a id="author">beyond</a>
				</p>		
	</footer>	

			
</body>
</html>

效果如下:



核心代码:

< picture > 
   < source  srcset= "img_smallflower.jpg"  media= "(max-width: 640px)" > 
   < source  srcset= "img_bigflowers.jpg" > 
   < img  src= "img_flowers.jpg"  alt= "Flowers" > 
< /picture >

srcset 属性的必须的,定义了图片资源。

media 属性是可选的,可以在媒体查询的 CSS @media 规则 查看详情。

对于不支持<picture元素的浏览器你也可以定义<img>元素来替代。


扩展阅读

《响应式图片101》:介绍为什么需要响应式图片以及如何选择正确的响应式图片解决方案。



响应式 Web 设计 - 视频(Video)


使用 width 属性

如果 width 属性设置为 100%,视频播放器会根据屏幕大小自动调整比例:

注意:这个样式,视频可以超过原始大小

代码如下:

<!DOCTPYE html>
<html lang="zh">
<head>
	<link rel="icon" href="beyond.jpg" type="image/x-icon"/>
	<meta charset="UTF-8">
	<meta name="author" content="beyond">
	<meta http-equiv="refresh" content="520">
	<meta name="description" content="免费零基础教程">
	<meta name="viewport" content="width=device-width, 
	initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0,user-scalable=0" />
	<meta name="keywords" content="HTML,CSS,JAVASCRIPT">
	<title>beyondの心中の动漫神作</title>
	<link rel="stylesheet" type="text/css" href="beyondbasestylewhite3.css">

	<!--[if lt IE 9]>
		<script src="//apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"></script>
	<![endif]-->

	<style type="text/css">

		body{
			font-size: 100%;
			/*background-image: url("sakura4.png");
			background-repeat: no-repeat;
			background-position: center center;*/
			/*声明margin和padding是个好习惯*/
			margin: 0;
			padding: 0;
		}
		/*width:100%
		这样式,视频可以超过原始大小*/
		video {
			width: 100%;
			/*不加这个会比例失调*/
			height: auto;
		}
		
		
	</style>
</head>

<body>
		<h1 style="color:white;text-shadow:2px 2px 4px #000;letter-spacing:5px;" class="sgcontentcolor sgcenter">
				未 闻 花 名
		</h1>
		<video width="400" controls>
			<source src="anime.mp4" type="video/mp4" />
			<source src="anime.ogg" type="video/ogg" />
			Your browser does not support HTML5 video.
		</video>

	
		<p class="sgcontentcolor sgcenter" style="clear:left;">
				<b>注意:</b>调整窗口,width:100%<br/>
				视频可以超过原来的大小
		</p>

	<footer id="copyright">
				<p style="font-size:14px;text-align:center;font-style:italic;">
				Copyright © <a id="author">2018</a> Powered by <a id="author">beyond</a>
				</p>		
	</footer>	

			
</body>
</html>

效果如下:



核心代码:

video {
     width:  100%;
     height:  auto;
}

注意在以上实例中,视频播放器根据屏幕大小自动调整比例,且可以比原始尺寸还要大。

更多情况下我们可以使用 max-width 属性来替代。


使用 max-width 属性

如果 max-width 属性设置为 100%, 视频播放器会根据屏幕自动调整比例,但不会超过其原始大小

效果如下:


实例

video {
     max-width:  100%;
     height:  auto;
}

在html_282.html网页中,添加视频

我们可以在网页中添加视频。

以下实例视频根据 div 区域大小自动调整并占满整个 div 区域:

完整代码如下:

<!DOCTPYE html>
<html lang="zh">
<head>
	<link rel="icon" href="beyond.jpg" type="image/x-icon"/>
	<meta charset="UTF-8">
	<meta name="author" content="beyond">
	<meta http-equiv="refresh" content="520">
	<meta name="description" content="免费零基础教程">
	<meta name="viewport" content="width=device-width, 
	initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0,user-scalable=0" />
	<meta name="keywords" content="HTML,CSS,JAVASCRIPT">
	<title>beyondの心中の动漫神作</title>
	<link rel="stylesheet" type="text/css" href="beyondbasestylewhite3.css">

	<!--[if lt IE 9]>
		<script src="//apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"></script>
	<![endif]-->

	<style type="text/css">

		body{
			font-size: 100%;
			/*background-image: url("sakura4.png");
			background-repeat: no-repeat;
			background-position: center center;*/
			/*声明margin和padding是个好习惯*/
			margin: 0;
			padding: 0;
		}
		/*响应式布局,必须加这一句CSS3*/
		* {
			box-sizing: border-box;
		}

		/*这个是在它后面添加啥???空白文本???*/
		div.class_div_12row:after {
			content: "";
			clear: both;
			/*将啥转成了block块???*/
			display: block;
		}
		

		/*美化一下页面样式*/
		html {
			font-family: "Lucida Sans",sans-serif;
		}
		div.class_div_header {
			background-color: #9933cc;
			color: #fff;
			padding: 2px;
		}
		div.class_div_menu ul {
			list-style-type: none;
			margin: 0;
			padding: 0;
		}
		div.class_div_menu li {
			padding: 8px;
			margin-bottom: 7px;
			background-color: #33b5e5;
			color: #fff;
			/*这个是什么鬼参数*/
			box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
		}
		div.class_div_menu li:hover {
			background-color: #0099cc;
		}

		/*新增的右侧边栏*/
		div.class_div_rightaside {
			background-color: #33b5e5;
			padding: 5px;
			color: #fff;
			text-align: center;
			font-size: 14px;
			/*各个参数是什么鬼???*/
			box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
		}
		/*新增的底部栏*/
		div.class_div_footer {
			background-color: rgba(17,134,193,0.2);
			/*color: #fff;*/
			text-align: center;
			font-size: 12px;
			padding: 3px;
		}

		/*这个又是啥选择器???
		  默认是移动优先设计
		  手机上每一列全宽100%*/
		[class*="col-"] {
			width: 100%;
		}
		/*全部左浮动*/
		[class*="col-"] {
			float: left;
			padding: 2px;
		}
		@media only screen and (min-width: 640px) {
			/*大于640时,也就是来到了平板屏幕的世界*/
			.col-m-1 {width: 8.33%;}
			.col-m-2 {width: 16.66%;}
		    .col-m-3 {width: 25%;}
		    .col-m-4 {width: 33.33%;}
		    .col-m-5 {width: 41.66%;}
		    .col-m-6 {width: 50%;}
		    .col-m-7 {width: 58.33%;}
		    .col-m-8 {width: 66.66%;}
		    .col-m-9 {width: 75%;}
		    .col-m-10 {width: 83.33%;}
		    .col-m-11 {width: 91.66%;}
		    .col-m-12 {width: 100%;}
		}
		@media only screen and (min-width: 768px) {
			/*大于768时,也就是来到了电脑屏幕的世界*/
			.col-1 {width: 8.33%;}
			.col-2 {width: 16.66%;}
			.col-3 {width: 25%;}
			.col-4 {width: 33.33%;}
			.col-5 {width: 41.66%;}
			.col-6 {width: 50%;}
			.col-7 {width: 58.33%;}
			.col-8 {width: 66.66%;}
			.col-9 {width: 75%;}
			.col-10 {width: 83.33%;}
			.col-11 {width: 91.66%;}
			.col-12 {width: 100%;}
		}

		/*新增视频*/
		video {
			width: 100%;
			height: auto;
		}
	</style>
</head>

<body>
<div class="class_div_header">
	<h1>光辉岁月</h1>
</div>

<div class="class_div_12row">
	<div class="col-3 col-m-3 class_div_menu">
		<ul>
			<li>首页</li>
			<li>APP</li>
			<li>民间偏方</li>
			<li>动漫</li>
		</ul>
	</div>

	<div class="col-6 col-m-9">
		<h1 style="color:white;text-shadow:2px 2px 4px #000;letter-spacing:5px;" class="sgcontentcolor sgcenter">
				未 闻 花 名
		</h1>
		<p>
				在我们走过的季节里,路旁盛开的花朵也在不断变化,那个季节盛开的花是叫什么来着?轻轻摇曳着,一碰会微微刺痛,靠近一闻,隐约有股青涩的阳光的气息。那气息渐渐地淡去,我们也在慢慢长大。可是,那朵花一定还在某个地方盛开着……对,我们永远都会继续实现那朵花的愿望。
		</p>
		<video width="400" controls>
			<source src="anime.mp4" type="video/mp4" />
			<source src="anime.ogg" type="video/ogg" />
			Your browser does not support HTML5 video.
		</video>
	</div>

	<div class="col-3 col-m-12">
		<div class="class_div_rightaside">
			<h2>龙与虎</h2>
			<p>讲述的是逢坂大河与高须龙儿之间的...</p>
			<h2>轻音少女</h2>
			<p>号称强国源泉,第一次发现没有男主的动漫也可以这么好看!</p>
		</div>
	</div>
	
</div>

<div class="class_div_footer">
	<footer id="copyright">
				<p style="font-size:14px;text-align:center;font-style:italic;">
				Copyright © <a id="author">2018</a> Powered by <a id="author">beyond</a>
				</p>		
	</footer>	
</div>
			
</body>
</html>

效果如下:


 

实例

video {
     width:  100%;
     height:  auto;
}



响应式 Web 设计 - 框架 Bootstrap

本章节为大家介绍响应式 Web 设计框架 Bootstrap。

Bootstrap,来自 Twitter,是目前最受欢迎的前端框架。

Bootstrap 是基于 HTML、CSS、JAVASCRIPT 的,它简洁灵活,使得 Web 开发更加快捷。

Bootstrap支持HTML和CSS规范,是由CSS的动态Less语言写成。

实例

< !DOCTYPE  html >
< html  lang= "en" >
< head >
< title >Bootstrap Example < /title >
< meta  charset= "utf-8" >
< meta  name= "viewport"  content= "width=device-width, initial-scale=1" >
< link  rel= "stylesheet" href= "http://apps.bdimg.com/libs/bootstrap/3.3.4/css/bootstrap.min.css" >
< script  src= "http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js" > < /script >
< script  src= "http://apps.bdimg.com/libs/bootstrap/3.3.4/js/bootstrap.min.js" > < /script >
< /head >
< body >

< div  class= "container" >
   < div  class= "jumbotron" >
     < h1 >我的第一个 Bootstrap 页面 < /h1 >
   < /div >
   < div  class= "row" >
     < div  class= "col-sm-4" >
      ...
     < /div >
     < div  class= "col-sm-4" >
      ...
     < /div >
     < div  class= "col-sm-4" >
    ...
     < /div >
   < /div >
< /div >

< /body >
< /html >

不知所云 »

更多内容,敬请期待我们的 Bootstrap 教程

未完待续,下一章节,つづく


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
前言<br><br>第一部分 Web设计核心问题<br><br>第1章 什么是Web设计 <br><br>1.1 Web设计的金字塔 <br><br>1.2 建设Web站点 <br><br>1.3 为用户建设 <br><br>1.4 从纸张到软件 <br><br>1.5 Web的图形用户界面传统 <br><br>1.6 内容的关注 <br><br>1.7 外观问题 <br><br>1.8 形式和功能的平衡 <br><br>1.9 什么是好的Web设计 <br><br>1.10 探索Web设计 <br><br>1.11 所见即所想 <br><br>1.12 小结 <br><br>第2章 Web设计进程 <br><br>2.1 进程需求 <br><br>2.2 特别的Web进程 <br><br>2.3 基本的Web进程模型 <br><br>2.3.1 修正瀑布模型 <br><br>2.3.2 联合应用开发模型 <br><br>2.4 Web站点项目的途径 <br><br>2.5 目标和问题 <br><br>2.5.1 集体讨论 <br><br>2.5.2 缩小目标 <br><br>2.6 访问者 <br><br>2.7 需求 <br><br>2.8 站点规划 <br><br>2.9 分割的设计阶段 <br><br>2.9.1 块的组合 <br><br>2.9.2 屏幕和纸张的组合图 <br><br>2.9.3 模拟站点 <br><br>2.10 Beta版站点实现 <br><br>2.11 测试 <br><br>2.12 发布及以后的问题 <br><br>2.13 欢迎来到真实世界 <br><br>2.14 小结 <br><br>第3章 为用户设计 <br><br>3.1 可用性 <br><br>3.2 谁是Web用户 <br><br>3.3 用户的共同特征 <br><br>3.4 记忆力 <br><br>3.5 响应和反应时间 <br><br>3.6 激励问题的处理 <br><br>3.6.1 极限 <br><br>3.6.2 鸡尾酒会效应 <br><br>3.6.3 感觉适应 <br><br>3.7 移动能力 <br><br>3.8 用户的世界 <br><br>3.9 用户的一般类型 <br><br>3.10 Web规则 <br><br>3.11 易访问性 <br><br>3.12 建设可用的站点 <br><br>3.13 可用性超过一切 <br><br>3.14 谁在控制Web体验 <br><br>3.15 小结 <br><br>第二部分 站点组织和浏览<br><br>第4章 站点类型和体系结构 <br><br>4.1 一般Web站点类型 <br><br>4.2 动态站点 <br><br>4.3 站点结构 <br><br>4.3.1 逻辑站点组织模型 <br><br>4.3.2 层次结构 <br><br>4.4 用户和站点结构 <br><br>4.5 站点的深与浅 <br><br>4.6 Web站点的特殊类型 <br><br>4.6.1 商业站点 <br><br>4.6.2 信息站点 <br><br>4.6.3 娱乐站点 <br><br>4.6.4 导航站点 <br><br>4.6.5 社区站点 <br><br>4.6.6 艺术站点 <br><br>4.6.7 个人站点 <br><br>4.7 选择站点结构 <br><br>4.8 小结 <br><br>第5章 导航理论与实践 <br><br>5.1 导航 <br><br>5.2 我在哪? <br><br>5.2.1 Web上的精确定位:URL <br><br>5.2.2 网页和站点标签 <br><br>5.2.3 网页、站点的样式和位置 <br><br>5.2.4 我曾到过哪? <br><br>5.3 我能去哪? <br><br>5.4 导航位置 <br><br>5.4.1 顶部导航 <br><br>5.4.2 底部导航 <br><br>5.4.3 左导航 <br><br>5.4.4 右导航 <br><br>5.4.5 中心导航 <br><br>5.5 导航的一致性 <br><br>5.6 导航和滚动 <br><br>5.7 导航和鼠标移动 <br><br>5.8 帧 <br><br>5.8.1 帧问题 <br><br>5.8.2 使用帧 <br><br>5.9 子窗口 <br><br>5.10 书签设置 <br><br>5.11 小结 <br><br>第6章 链接:文本、按钮、图标及图形 <br><br>6.1 基本的Web链接模型 <br><br>6.1.1 结构和非结构链接的比较 <br><br>6.1.2 静态和动态链接 <br><br>6.2 链接形式的分类 <br><br>6.2.1 文本链接 <br><br>6.2.2 图形文本链接 <br><br>6.2.3 按钮 <br><br>6.2.4 图标 <br><br>6.2.5 图像映射 <br><br>6.2.6 其他链接方式 <br><br>6.3 链接的实现问题:可用性、反馈和支持 <br><br>6.3.1 可用的链接 <br><br>6.3.2 滚动 <br><br>6.3.3 理解用户的期望 <br><br>6.4 使用范围注释 <br><br>6.4.1 TITLE属性 <br><br>6.4.2 滚动信息 <br><br>6.4.3 状态条信息 <br><br>6.5 链接的键盘支持 <br><br>6.6 高级的Web链接模型 <br><br>6.7 链接的维护 <br><br>6.8 小结 <br><br>第7章 搜索与设计 <br><br>7.1 网际搜索 <br><br>7.2 Web搜索总论 <br><br>7.3 用户搜索方式 <br><br>7.4 搜索引擎如何工作 <br><br>7.4.1 收集网页 <br><br>7.4.2 索引页 <br><br>7.5 搜索引擎改进 <br><br>7.5.1 添加到搜索引擎 <br><br>7.5.2 自动排斥 <br><br>7.5.3 Robots.txt <br><br>7.5.4 由<META>控制自动排斥 <br><br>7.6 优化搜索引擎 <br><br>7.6.1 <META>标签 <br><br>7.6.2 标题和文件命名 <br><br>7.6.3 相关文本内容 <br><br>7.6.4 链接和切入点 <br><br>7.6.5 花招 <br><br>7.6.6 标题广告 <br><br>7.7 对本地搜索的需要 <br><br>7.8 添加搜索工具的过程 <br><br>7.9 设计搜索界面 <br><br>7.9.1 访问搜索 <br><br>7.9.2 设计一个基本的搜索界面 <br><br>7.10 高级搜索窗体的设计 <br><br>7.11 结果页面设计 <br><br>7.12 小结 <br><br>第8章 站点映像、索引、其他导航及用户<br><br> 帮助 <br><br>8.1 不只是搜索 <br><br>8.2 站点映像 <br><br>8.2.1 文本方式站点映像 <br><br>8.2.2 图形站点映像 <br><br>8.3 设计站点映像 <br><br>8.4 显示范围和目的地选择 <br><br>8.5 创建站点映像 <br><br>8.6 “地理”导航的好处 <br><br>8.7 站点索引 <br><br>8.8 漫游 <br><br>8.9 帮助系统 <br><br>8.9.1 何时使用帮助 <br><br>8.9.2 复杂的帮助系统 <br><br>8.10 术语表 <br><br>8.11 “什么是最新的”部分 <br><br>8.12 小结 <br><br>第三部分 网页设计的要素<br><br>第9章 网页类型与布局 <br><br>9.1 什么是网页 <br><br>9.2 网页尺寸 <br><br>9.3 网页边距 <br><br>9.4 网页类型 <br><br>9.5 入口网页 <br><br>9.5.1 飞出网页 <br><br>9.5.2 主页 <br><br>9.5.3 子页:导航与内容的比较 <br><br>9.5.4 内容网页 <br><br>9.5.5 任务相关网页 <br><br>9.6 退出网页 <br><br>9.7 Web设计学派 <br><br>9.7.1 文本设计 <br><br>9.7.2 隐喻和主题设计 <br><br>9.7.3 基于图形用户界面的设计 <br><br>9.7.4 非常规设计 <br><br>9.8 布局示例 <br><br>9.8.1 TLB网页 <br><br>9.8.2 标题-页脚网页 <br><br>9.8.3 浮动窗口网页 <br><br>9.8.4 可伸展网页 <br><br>9.9 通用站点外观之路 <br><br>9.10 小结 <br><br>第10章 文本 <br><br>10.1 媒体情况 <br><br>10.1.1 用图形控制文本 <br><br>10.1.2 举起你的双手投降 <br><br>10.1.3 现代的Baskerville <br><br>10.2 排版术语101 <br><br>10.3 字体 <br><br>10.4 在Web网页中设置字体 <br><br>10.5 使用可下载的字体 <br><br>10.5.1 Netscape 的动态字体 <br><br>10.5.2 微软的动态字体 <br><br>10.5.3 设置字体格式 <br><br>10.5.4 字体尺寸 <br><br>10.6 文本布局 <br><br>10.6.1 文本的对齐 <br><br>10.6.2 行长度 <br><br>10.6.3 行间距 <br><br>10.6.4 字母间距及词间距 <br><br>10.7 设置字体层次 <br><br>10.7.1 标题和副标题 <br><br>10.7.2 表示段及节 <br><br>10.8 表格的格式化 <br><br>10.9 细节 <br><br>10.10 特殊文本的布局 <br><br>10.11 用于Web的文本设计问题 <br><br>10.11.1 Web上的栏 <br><br>10.11.2 空白空间是好还是坏 <br><br>10.12 经常考虑媒体的使用 <br><br>10.13 写给Web <br><br>10.13.1 阅读与扫描的对比 <br><br>10.13.2 非线性写法 <br><br>10.13.3 危险的词 <br><br>10.14 小结 <br><br>第11章 颜色、图像及背景 <br><br>11.1 颜色基础 <br><br>11.2 Web上的颜色 <br><br>11.2.1 比特深度 <br><br>11.2.2 在Web上定义颜色 <br><br>11.2.3 浏览器安全颜色 <br><br>11.2.4 混合色 <br><br>11.2.5 HTML和颜色 <br><br>11.2.6 CSS 和颜色 <br><br>11.2.7 颜色的再生问题 <br><br>11.3 颜色与可用性 <br><br>11.3.1 颜色的含义 <br><br>11.3.2 对比度问题 <br><br>11.4 图像 <br><br>11.4.1 使用图像 <br><br>11.4.2 HTML和图像:<IMG>标签 <br><br>11.4.3 图像类型 <br><br>11.4.4 与图像相关的问题 <br><br>11.4.5 分割图像 <br><br>11.4.6 Web中基于矢量的艺术: Flash <br><br>11.5 背景图像 <br><br>11.6 小结 <br><br>第12章 利用GUI特性创建交互性 <br><br>12.1 网站和传统的GUI <br><br>12.2 GUI设计的含义 <br><br>12.3 窗口 <br><br>12.4 全屏窗口 <br><br>12.5 子窗口 <br><br>12.5.1 警告 <br><br>12.5.2 确认 <br><br>12.5.3 提示 <br><br>12.6 窗体 <br><br>12.6.1 标签 <br><br>12.6.2 单行文本区 <br><br>12.7 密码文本区 <br><br>12.7.1 多行文本的输入 <br><br>12.7.2 复选框 <br><br>12.7.3 单选按钮 <br><br>12.8 下拉式菜单 <br><br>12.9 滚动列表 <br><br>12.10 按钮 <br><br>12.10.1 复位按钮 <br><br>12.10.2 提交按钮 <br><br>12.10.3 图像按钮 <br><br>12.10.4 文件上载控制 <br><br>12.11 可用的窗体 <br><br>12.11.1 请求的文本区 <br><br>12.11.2 使用Tab键的窗体 <br><br>12.11.3 第一文本区的聚焦 <br><br>12.11.4 键盘的快捷方式 <br><br>12.12 窗体校验 <br><br>12.12.1 文本区屏蔽 <br><br>12.12.2 文本区的失效 <br><br>12.12.3 只读文本区 <br><br>12.12.4 缺省数据 <br><br>12.12.5 Internet Explorer自动完成 <br><br>12.13 先进的Web GUI特性 <br><br>12.13.1 树形导航 <br><br>12.13.2 Tabbed对话框 <br><br>12.13.3 游标 <br><br>12.13.4 上下文菜单 <br><br>12.14 什么时候Web应用才是真正的应用 <br><br>12.15 小结 <br><br>第四部分 技术与Web设计<br><br>第13章 Web技术及其对Web设计的影响 <br><br>13.1 Web技术问题:一桶冰冷的水 <br><br>13.2 浏览器 <br><br>13.3 HTML <br><br>13.4 HTML有规则吗? <br><br>13.4.1 HTML规则 <br><br>13.4.2 XHTML <br><br>13.5 面向表示的HTML <br><br>13.6 CSS <br><br>13.6.1 CSS的使用 <br><br>13.6.2 CSS的实践 <br><br>13.7 创作HTML/CSS页 <br><br>13.8 XML <br><br>13.9 编程与Web设计 <br><br>13.10 服务器端的编程 <br><br>13.11 客户端的编程 <br><br>13.11.1 Helplers <br><br>13.11.2 插入件 <br><br>13.11.3 ActiveX <br><br>13.11.4 Java <br><br>13.12 JavaScript <br><br>13.12.1 JavaScript版本 <br><br>13.12.2 一致通过的脚本 <br><br>13.12.3 对象检测 <br><br>13.12.4 处理不支持脚本的浏览器 <br><br>13.12.5 JavaScript 中错误的捕获 <br><br>13.12.6 链接的脚本 <br><br>13.12.7 JavaScript样式 <br><br>13.12.8 挤压的JavaScript <br><br>13.12.9 使用JavaScript <br><br>13.13 Cookies <br><br>13.14 Web设计中的多媒体 <br><br>13.15 动画 <br><br>13.16 声音 <br><br>13.16.1 数字音频基础 <br><br>13.16.2 音频文件格式和压缩 <br><br>13.16.3 简单的Web音频 <br><br>13.16.4 简单音频的实践 <br><br>13.16.5 流音频 <br><br>13.16.6 可用性和音频文件 <br><br>13.17 视频 <br><br>13.17.1 数字视频基础 <br><br>13.17.2 视频文件格式和压缩 <br><br>13.18 小结 <br><br>第14章 站点发送与管理 <br><br>14.1 发送的重要性 <br><br>14.2 Web协议 <br><br>14.3 域名服务 <br><br>14.4 Web服务器 <br><br>14.4.1 Web服务器的构成 <br><br>14.4.2 Web服务器软件 <br><br>14.4.3 Web服务器的位置 <br><br>14.5 外购的Web宿主环境 <br><br>14.5.1 共享式宿主 <br><br>14.5.2 专用的宿主 <br><br>14.6 管理Web服务器 <br><br>14.7 内容管理 <br><br>14.8 使用情况分析 <br><br>14.9 隐私 <br><br>14.10 内容焦点 <br><br>14.11 小结 <br><br>第五部分 未来方向<br><br>第15章 Web设计的未来 <br><br>15.1 不久的将来 <br><br>15.1.1 HTML的遗产 <br><br>15.1.2 大杂烩 <br><br>15.1.3 XML:对一切都好还是一无是处 <br><br>15.1.4 用户准则 <br><br>15.2 宽带的兴起 <br><br>15.2.1 不基于PC的Web访问 <br><br>15.2.2 浏览器变成了日用品 <br><br>15.2.3 无限制的Web访问 <br><br>15.3 团体效果 <br><br>15.4 内容过载问题 <br><br>15.5 Web生活方式 <br><br>15.6 小结 <br><br>第六部分 附 录<br><br>附录A Web设计的核心准则 <br><br>附录B 站点评估过程示例 <br><br>附录C 字体 <br><br>附录D 参考颜色

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值