[html5] 学习笔记-响应式布局
1、响应式布局介绍
响应式布局是2010年5月份提出的一个概念,简而言之,就是一个网站能够兼容多个终端——而不是每一个终端做一个特定的版本。这个概念是为了兼容移动互联网浏览而诞生的,其目的是为用户提供更加舒适的界面和更好的用户体验。
优点:面对不同分辨率设备灵活性强、能够快捷解决多设备显示适应问题
缺点:兼容各种设备工作量大,效率低下;代码累赘,会出现隐藏无用的元素,加载时间长
2、响应式布局的实现
CSS中的Media Query(媒介查询):设备宽高:device-width , device-height 渲染窗口的宽和高:width height 设备的手持方向:orientation 设备的分辨率:resolution
使用方法:外联、内嵌样式
实现屏幕宽度大于640Px时,背景为红色;屏幕宽度小于640px时,背景为蓝色:
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8">
- <title></title>
- <link href="4.css" type="text/css" rel="stylesheet" media="only screen and (max-width: 640px)">
- <style>
- @media screen and (min-width:640px) {
- body{
- background-color: red;
- }
- }
- </style>
- </head>
- <body></body>
- </html>
其中的4.css:
- body{
- background-color: blue;
- }
3、响应式布局实例操作
html代码:
- <!doctype html>
- <html>
- <head lang="en">
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width,initial-scale=1">
- <title></title>
- <link href="1.css" type="text/css" rel="stylesheet">
- </head>
- <body>
- <div class="heading"></div>
- <div class="container">
- <div class="left"></div>
- <div class="main"></div>
- <div class="right"></div>
- </div>
- <div class="footing"></div>
- </body>
- </html>
对应的css文件:
- *{
- margin:0px;
- padding:0px;
- }
- .heading,
- .container,
- .footing{
- margin: 10px auto;
- }
- *heading{
- height:100px;
- background-color: chocolate;
- }
- .left,
- .right,
- .main{
- background-color: cornflowerblue;
- }
- .footing{
- height:100px;
- background-color: aquamarine;
- }
- @media screen and (min-width: 960px){
- .heading,
- .container,
- .footing{
- width:960px;
- }
- .left,
- .main,
- .right{
- float:left;
- height: 500px;
- }
- .left,
- .right
- {
- width: 200px;
- }
- .main{
- margin-left: 5px;
- margin-right: 5px;
- width:550px;
- }
- .container{
- height:500px;
- }
- }
- @media screen and (min-width: 600px) and (max-width: 960px){
- .heading,
- .container,
- .footing{
- width: 600px;
- }
- .left,
- .main
- {
- float: left;
- height: 400px;
- }
- .right{
- display: none;
- }
- .left{
- width: 160px;
- }
- .main{
- width: 435px;
- margin-left: 5px;
- }
- .container{
- height: 400px;
- }
- }
- @media screen and (max-width: 600px){
- .heading,
- .container,
- .footing{
- width: 400px;
- }
- .left,
- .right{
- width: 400px;
- height: 100px;
- }
- .main{
- margin-top: 10px;
- width: 400px;
- height: 200px;
- }
- .right{
- margin-top: 10px;
- }
- .container{
- height: 420px;
- }
- }
[html5] 学习笔记-响应式布局的更多相关文章
- CSS学习笔记——响应式布局
响应式布局 响应式布局是现在很流行的一个设计理念,随着移动互联网的盛行,为解决如今各式各样的浏览器分辨率以及不同移动设备的显示效果,设计师提出了响应式布局的设计方案.所谓的响应式布局,就是一个网站能够 ...
- Bootstrap学习笔记-响应式布局原理
响应式布局的原理就是利用css3中@media媒体来实现的 <html> <head> <meta charset="utf-8"> <t ...
- html5 + css3 + jQuery + 响应式布局设计
1. [代码][HTML]代码 <!DOCTYPE html><html dir="ltr" lang="zh-CN">< ...
- SharePoint 2013 的HTML5特性之响应式布局
今天偶然看到一本书<Pro SharePoint 2013 Branding and Responsive Web Development>,看到SharePoint 2013基于HTML ...
- SharePoint 2013的HTML5特性之响应式布局
今天偶然看到一本书<Pro SharePoint 2013 Branding and Responsive Web Development>,看到SharePoint 2013基于HTML ...
- CSS3与页面布局学习笔记(四)——页面布局大全(负边距、双飞翼、多栏、弹性、流式、瀑布流、响应式布局)
一.负边距与浮动布局 1.1.负边距 所谓的负边距就是margin取负值的情况,如margin:-100px,margin:-100%.当一个元素与另一个元素margin取负值时将拉近距离.常见的功能 ...
- HTML5学习总结-番外05 响应式布局
1. 响应式布局 响应式布局是2015年5月份提出的一个概念,简而言之,就是一个网站能够兼容多个终端,而不是为每个终端做一个特定的版本.这个概念是为解决移动互联网浏览而诞生的.其目的是为用户提欧共更加 ...
- [学习笔记]viewport定义,弹性布局,响应式布局
一,移动端宽度设置viewport视图窗口,<meta name="viewport" content="width=device-width,initial-sc ...
- CSS3学习笔记--media query 响应式布局
语法:@media screen and (min-width: 320px) and (max-width : 479px) media属性后面跟着的是一个 screen 的媒体类型(上面说过的十种 ...
随机推荐
- Oracle存储过程中如何使用游标
--本存储过程的功能:把test_tbl2中与test_tbl1中ID相同但salary不同的记录中的salary的值更新为test_tbl1中的salary的值--创建存储过程create or r ...
- iOS navigationBar 的isTranslucent属性
苹果文档: A Boolean value indicating whether the navigation bar is translucent (YES) or not (NO). The de ...
- pip install -r requirements.txt 安装mysqldb失败 解决方案
在pip.log中出现sh: 1: mysql_config: not found等一坨报错,因为没有安装另一个包: 只要原因是没有安装:libmysqlclient-dev sudo apt-get ...
- (中等) POJ 1703 Find them, Catch them,带权并查集。
Description The police office in Tadu City decides to say ends to the chaos, as launch actions to ro ...
- (简单) POJ 1511 Invitation Cards,SPFA。
Description In the age of television, not many people attend theater performances. Antique Comedians ...
- (简单) UVA 11624 Fire! ,BFS。
Description Joe works in a maze. Unfortunately, portions of the maze have caught on fire, and the ow ...
- shell字符串操作之cut---实现字符串截取
shell中(字符串截取) cut是以每一行为一个处理对象的,这种机制和sed是一样的.(关于sed的入门文章将在近期发布) 2 cut一般以什么为依据呢? 也就是说,我怎么告诉cut我想定位到的剪切 ...
- getElementsByTagName("div")和$("div")区别
作者:zccst <body> <div class="selected">1</div> <div class="select ...
- html页面头部里的meta
作者:zccst html中的http-equiv属性应用详解 一.简介 http-equiv 属性 -- HTTP协议的响应头报文 此属性出现在meta标签中 此属性用于代替name,HTTP服务器 ...
- MySQL常用命令总结3
id SMALLINT UNSIGNED [AUTO_INCREMENT] PRIMARY KEY, //把id定义为主键且自动排号,每张数据表只有一个主键,不能为NULL,确保记录唯一性 //省略a ...