“响应式Web设计”的出现背景

在很早之前(或者在目前也存在此情况),我们写出来的前端页面可能都还是固定宽度的,这种页面如果仅仅是在我们的笔记本电脑或者一般的台式机来加载浏览的话可能差别不是很大,虽然有较小的差别,但不太会超出我们的忍耐程度。但是呢,目前我们浏览网页的方式发生了巨大的变化,这就得益于各种浏览设备的出现了,例如:手机、平板、大比例展示屏……

那如果固定宽度的页面加载在笔记本或者台式机里面产生的细小差别我们能忍受的话,网页一旦加载到手机或大屏设备上,此时产生的差别我们是绝对不能接受的。这时候就需要一种解决方法了:能够让同一网页能适配各种不同的浏览设备,即:可以在不同的浏览设备中可以呈现出不同的布局或功能。

“响应式Web设计”的提出

此概念是国外的一位技术大牛在他的一篇文章中提出的,这篇文章运用了已经实现的三种技术(弹性网格布局、弹性图片/媒体、媒体查询)来提供了一个解决方案,此方案就是——响应式Web设计。

如果非要给他一个定义的话,那就记住下面的文字吧:响应式Web设计,就是网页内容会随着访问它的视口及设备的不同而呈现出不同的样式。

学习“响应式Web设计”的技术基础

响应式Web设计的学习并不需要很高的门槛,你只要有HTML5和CSS3的基础就可以学习。

“响应式Web设计”的代码结构

此部分粘贴一份响应式Web设计的示例代码,其目的不是让你立即明白每一行的代码代表的含义,而是让你从整体上有一个认知——响应式“Web设计”的代码原来是这样写的,这就可以啦,废话不多说,我们先走马观花的看一下代码吧。

HTML部分:

<!doctype html>
<html class="no-js" lang="en"><head><meta charset="utf-8"><title>Our first responsive web page with HTML5 and CSS3</title><meta name="description" content="A basic responsive web page – an example from Chapter 1"><meta name="viewport" content="width=device-width"><link rel="stylesheet" href="css/styles.css"></head><body><div class="Header"><a href="/" class="LogoWrapper"><img src="img/SOC-Logo.png" alt="Scone O'Clock logo" /></a><p class="Strap">Scones: the most resplendent of snacks</p></div><div class="IntroWrapper"><p class="IntroText">Occasionally maligned and misunderstood; the scone is a quintessentially British classic.</p><div class="MoneyShot"><img class="MoneyShotImg" src="img/scones.jpg" alt="Incredible scones" /><p class="ImageCaption">Incredible scones, picture from Wikipedia</p></div></div><p>Recipe and serving suggestions follow.</p><div class="Ingredients"><h3 class="SubHeader">Ingredients</h3><ul><li>350g self-raising flour, and a little spare for dusting</li><li>¼ tsp salt</li><li>1 tsp baking powder</li><li>85g butter, cut into cubes</li><li>3 tbsp caster sugar</li><li>175ml milk</li><li>1 tsp vanilla extract</li><li>squeeze lemon juice (see Know-how below)</li><li>beaten egg, to glaze</li><li>jam and clotted cream, to serve</li></ul></div><div class="HowToMake"><h3 class="SubHeader">Method</h3><ol class="MethodWrapper"><li>Heat the oven to 220&deg;C (or gas mark 7). Tip the flour into a large bowl along with the salt and baking powder, then mix it all up. Add the butter in, then rub the butter in with your fingers until the mix looks like fine crumbs. When that is done, stir in the sugar.</li><li>Put the milk into a jug and heat in the microwave for about 20-30 seconds. It should be warm but not hot. Add the vanilla and lemon juice to the milk and then put that to one side and but a baking tray in the oven to warm.</li><li>Make a well in the dry mix, then add the liquid and combine it quickly with a cutlery knife – it will seem pretty wet at first. Spread some flour onto the work surface and tip the dough out. Dredge the dough and your hands with a little more flour, then fold the dough over 2-3 times until it's smoother. Now pat it into a round shape about 4cm deep.</li><li>Take a 5cm cutter (Pro-tip – smooth-edged cutters tend to cut more cleanly, giving a better rise) and dip it into some flour. Plunge into the dough, then repeat until you have four scones. By this point you’ll probably need to press what's left of the dough back into a round to cut out another four.</li><li>Brush the tops with beaten egg, then place onto the hot baking tray.</li><li>Bake for 10 minutes until risen and golden on the top. Eat just warm or cold on the day of baking, generously (and I do mean generously) topped with jam and clotted cream. </li><li>If freezing, freeze once cool. Defrost, then put in a low oven (about 160&deg;C) for a few minutes to refresh.</li></ol></div></body>
</html>

CSS部分

* {box-sizing: border-box;
}body {padding: 1rem .5rem;font-size: 1.3rem;line-height: 1.2;max-width: 60rem;margin: 0 auto;color: #333;
}img {max-width: 100%;
}.Header {text-align: center;border-bottom: 8px double #f9f9f9;margin-bottom: 2rem;padding-bottom: 1rem;
}.Strap {font-size: 1rem;
}.MoneyShot {position: relative;
}.MoneyShotImg {border: 6px solid #e8cfa9;border-radius: 4px;
}.LogoWrapper {display: block;
}.ImageCaption {font-size: .75rem;position: absolute;bottom: .5rem;right: 1rem;
}.IntroText {font-size: 1.8rem;font-style: italic;
}.MethodWrapper li {padding: .4rem 0;
}.MethodWrapper li:after {content: "✼";display: block;text-align: center;margin: 1rem 0 .5rem 0;color: #eee;
}@media screen and (min-width: 50rem) {body {border-left: 4px solid #f9f9f9;border-right: 4px solid #f9f9f9;padding: 1rem 2rem;}.IntroWrapper {display: table;table-layout: fixed;width: 100%;}.MoneyShot,.IntroText {display: table-cell;width: 50%;vertical-align: middle;text-align: center;}.IntroText {padding: .5rem;font-size: 2.5rem;text-align: left;position: relative;}.Ingredients {font-size: .9rem;float: right;padding: 1rem;margin: 0 0 .5rem 1rem;border-radius: 3px;background-color: #ffffdf;border: 2px solid #e8cfa9;}.Ingredients h3 {margin: 0;}
}

喜欢折腾的你可能忍不住了吧,马上就想把代码复制粘贴跑一下,但是还不行哦,我们需要准备两张图片去替换掉代码中引用的图片,这样的话就可以跑代码啦,我们可以换不同的设备来查看此页面的布局变化(最简单的就是改变浏览器的大小来查看),如图:

图 页面全屏下的样式

图 浏览器宽度变小后的样式

通过比对上面的两种布局,你是否对响应式设计有了大概的了解呢,我们就只写了一份HTML和CSS代码,但是他可以在不同的设备条件下显示不同的布局,是不是很神奇,哈哈,本文的任务完成了,就是让你对响应式设计有一个整体的认知。

总结

此篇文章仅仅简单介绍了一下响应式Web设计的由来以及大概含义,因为本人在刚开始学习的时候查阅资料发现并没有一篇文章将此概念简单的介绍,一上来就是各种方法、各种步骤的操作介绍,让人没有一个整体的了解,哈哈,我这样说可能会招很多大佬的揍,在此请各位大佬高抬贵手啦。接下来的文章中会逐一介绍响应式Web设计涉及到的各个知识点,请各位关注呦

01 “响应式Web设计”——概述相关推荐

  1. 下一代响应式Web设计:组件驱动式Web设计

    自从著名设计师 Ethan Marcotte(@beep)在 A List Apart上发表了一篇名为< Responsive Web Design>的文章之后,响应式网页设计(RWD,即 ...

  2. 什么是响应式Web设计?怎样进行?

    开 始第一篇.老规矩,先无聊的谈论天气一类的话题.十一长假,天气也终于开始有些秋天的味道,坐在屋里甚至觉得需要热咖啡.话说两年前也是在国庆假期里开始 做Joomla文档翻译的:长假好时光,总会可以抽出 ...

  3. CSS3: Media Query实现响应式Web设计

    十一长假已然过去了一大半.今天倒真是晴朗的不行,向窗外望去几乎可以看到阳光穿过凉爽的空气一缕缕洒落下来的样子.自从不再是学生,对每年的几次 长假就无比珍惜,想方设法让每一天都尽量过的饱满一些:夜里闭上 ...

  4. 响应式Web设计:HTML5和CSS3实战 读书笔记

    响应式Web设计:HTML5和CSS3实战 Responsive Web Design with HTML5 and CSS3 By : Pandao    pandao####vip.qq.com  ...

  5. [书籍精读]《响应式Web设计 HTML5和CSS3实战(第二版)》精读笔记分享

    写在前面 书籍介绍:本书主要讲解了如何运用HTML5和CSS3来进行响应式Web设计,使页面的设计与开发根据用户行为以及设备环境(系统平台.屏幕尺寸.屏幕定向等)来进行相应的响应和调整. 我的简评:响 ...

  6. 层出不穷的终端设备适配需求下 未来的响应式Web设计长什么样?

    作者:大貘 响应式Web设计诞生已久,本文将带你了解响应式Web设计的前世今生,以及组件式驱动Web设计带来了哪些新变化. 自从著名设计师Ethan Marcotte在 A List Apart上发表 ...

  7. 响应式Web设计读书笔记与实践

    前段时间在微博上看到了几个在当今前端圈中的大牛的撕逼大战,作为一个前端小白来说就只是看热闹的,热闹中看到了两本书,<无懈可击的Web设计>和<响应式Web设计>,前者没有买到纸 ...

  8. 通过响应式web设计,使本站支持手机浏览

    2019独角兽企业重金招聘Python工程师标准>>> 2014-01-28 14:49:14 现在越来越多的人通过手机来上网,手机由于屏幕尺寸的原因,当浏览为PC端浏览器设计的网页 ...

  9. 《响应式Web设计:HTML5和CSS3实践指南》——2.9节基于位置伪类的交替行样式

    本节书摘来自华章社区<响应式Web设计:HTML5和CSS3实践指南>一书中的第2章,第2.9节基于位置伪类的交替行样式,作者(美) Benjamin LaGrone,更多章节内容可以访问 ...

最新文章

  1. 搜索Idiot就出现特朗普图片,算法无罪!
  2. JsonCpp的简单使用方法
  3. 【❤️Mark一下❤️】markdown中写上标、下标
  4. poj 1987 树的分治
  5. vant 软键盘_移动端页面输入底部被软键盘遮挡问题
  6. ReviewForJob——快速排序(基于插入排序)+快速选择(快速排序变体)
  7. android tombstone发生过程,Android Tombstone解决步骤
  8. 安卓系统应用启动流程分析
  9. 【机器学习】分类算法sklearn-朴素贝叶斯算法
  10. 2020国开c语言程序设计1075,代号1253国开点大2017年6月春季学期本科期末考试《C语言程序设计》试题及答案.pdf...
  11. git代码托管 · 操作举例: “git bash here ”(全程操作讲解) - git命令篇
  12. CentOS安装图文教程
  13. php访问日记在哪,nginx访问日志在哪里
  14. 修改mysql限制ip_MySQL 修改账号的IP限制条件
  15. 探索新技术经验分享(六)logicaldoc二次开发探索
  16. IE插件加载问题调试
  17. 密码学·编码类密码·CTF常见考察密码
  18. 2020读书笔记 《马歇尔传记》
  19. java翻译后的文件扩展名_Java语言的源程序翻译成字节码之后的扩展名是.______。(填英文,小写)...
  20. vue数据传递--父传子-方法传递

热门文章

  1. 通过工作组在DAO中展开更有效的治理
  2. 亚信科技AntDB数据库荣获赛宝优选信创优秀解决方案奖
  3. ISCSI概念、构架、连接方式、组成和工作原理
  4. 博物馆文创:打造“最后一个展厅”
  5. difference_type解析
  6. VU33P加速计算卡设计资料第613篇:基于VU33P的双路100G光纤网络加速计算卡
  7. hdu 5439 Ponds(长春网络赛——拓扑排序+搜索)
  8. 0型系统, I型系统, II型系统对PID的影响
  9. 双系统安装(windows和linux)
  10. Cuda与cudnn对应关系