<!doctype html> <html> <head> <meta charset="utf-8"> <title>Media Queries模块</title> <style> @media screen and (min-width:260px){ .box{ background:#f60; width:400px; height:1000px; } } @media screen and (min-width:600px){ .box{ background-color:#60f; width:600px; height:1000px; } } @media screen and (min-width:800px){ .box{ background:#6f0; width:800px; height:1000px; } } </style> </head> <body> <div class="box"></div> </body> </html>
效果图:
<!doctype html> <html> <head> <meta charset="utf-8"> <title>案例</title> <style> html{ font-size:62.5%;} body{ margin:20px 0;} .box{ width:960px; margin:0 auto;} .content{ width:740px; float:left;} p{ line-height:600px; text-align:center; font-size:3rem; font-weight:bold; margin: 0 0 20px 0; color:#fff;} .cont{ width:520px; float:right; background:#656aba;} .left{ width:200px; float:left; background:#ff2dc4;} .right{ width:200px; float:right; background:#41db50;} @media screen and (min-width:1000px){ .box{ width:1000px;} .content{ width:780px; float:left;} .cont{ width:560px; float:right;} .left{ width:200px; float:left;} .right{ width:200px; float:right;} } @media screen and (min-width:640px) and (max-width:999px){ .box{ width:640px;} .content{ width:640px; float:none;} p{ line-height:400px;} .cont{ width:420px; float:right;} .left{ width:200; float:left;} .right{ width:100%; float:none; clear:both; line-height:150px;} } @media screen and (max-width:639px){ .box{ width:100%;} .content{ width:100%; float:none;} p{ line-height:300px;} .cont{ width:100%; float:none;} .left{ width:100%; float:none;} .right{ width:100%; float:none; clear:both; line-height:150px;} } </style> </head> <body> <div class="box"> <div class="content"> <p class="cont">cont</p> <p class="left">left</p> </div> <p class="right">right</p> </div> </body> </html>
效果图:
<!doctype html> <html> <head> <meta charset="utf-8"> <title>案例</title> <style> body{ margin:20px 0;} .box{ width:960px; margin:0 auto;} .content{ width:740px; float:left;} p{ line-height:600px; text-align:center; font-size:2em; font-weight:bold; margin: 0 0 20px 0; color:#fff;} .cont{ width:520px; float:right; background:#656aba;} .left{ width:200px; float:left; background:#ff2dc4;} .right{ width:200px; float:right; background:#41db50;} /*大于1000px的时候*/ @media screen and (min-width:1000px){ .box{ width:1000px;} .content{ width:780px; float:left;} .cont{ width:560px; float:right;} .left{ width:200px; float:left;} .right{ width:200px; float:right;} } /*最大不超过999像素 最小不小于640px*/ @media screen and (min-width:640px) and (max-width:999px){ .box{ width:640px;} .content{ width:640px; float:none;} p{ line-height:400px;} .cont{ width:420px; float:right;} .left{ width:200; float:left;} .right{ width:100%; float:none; clear:both; line-height:150px;} } /*最大不超过639px*/ @media screen and (max-width:639px){ .box{ width:100%;} .content{ width:100%; float:none;} p{ line-height:300px;} .cont{ width:100%; float:none;} .left{ width:100%; float:none;} .right{ width:100%; float:none; clear:both; line-height:150px;} } </style> </head> <body> <div class="box"> <div class="content"> <p class="cont">cont</p> <p class="left">left</p> </div> <p class="right">right</p> </div> </body> </html>
效果图:
相关推荐
最近在做一个自适应布局的项目,所以学了下自适应,下面是总结。此总结只做效果,不关注效率和代码优化。 1.css3 html中添加复制代码代码如下:<meta name=”viewport” content=”width=device-width,target-...
自适应布局我知道的两种方式 1.使用媒体查询,下面制定了几种适应方式,例如第一个表示屏幕宽度在320px-360px之间的,html字体大小适配为13.65px <style> @media only screen and (max-width: 360px) and ...
css2里面虽然支持@media属性,但是能实现的功能比较少,一般只用做打印的时候做特殊定义的CSS。 @media sMedia { sRules } 1.1、示例 // 设置显示器用字体尺寸 @media screen { BODY {font-size:12pt; } } // ...
Media Queries移动设备样式
第五章绘制图形 第六章多媒体播放 第七章本地存储 第八章离线应用程序 第九章通信API 第十章使用Web Workers处理线程 第十一章获取地理位置的信息 第十二章CSS 3概述 第十三章选择器 第十四章使用选择器在页面中插入...
@media all and (orientation : portrait) { /*竖屏*/ } @media all and (orientation : landscape) { /*横屏*/ } 指定手机端高度样式: @media screen and (max-width: 750px) @media screen and (min-width: 720...
Media Queries这功能是非常强大的,他可以让你定制不同的分辨率和设备,并在不改变内容的情况下,让你制作的web页面在不同的分辨率和设备下都能显示正常,并且不会因此而丢失样式。 首先来看一个简单的实例: 复制...
1.版本:matlab2022A,包含仿真操作录像,操作录像使用windows media player播放。 2.领域:SISO轨迹跟踪 3.仿真效果:仿真效果可以参考博客同名文章《基于自适应控制器的SISO轨迹跟踪matlab仿真》 4.内容:基于...
手写笔媒体查询Stylus mixins 可快速编写用于自适应和响应式设计的媒体查询安装用做: $ npm install stylus-media-queries --save用法 @import "../node_modules/stylus-media-queries/index.styl" ;+ max-screen ...
当今屏幕分辨率从320px(iPhone)到2560px(大屏显示器)或者更大。人们也不再仅仅用台式机来浏览网页,现在有手机,平板电脑...用CSS3媒体查询(Mediaquery)来检验屏幕分辨率,如果小于980px,页面宽度将会用自适应来取
响应式布局写的一个关于乌镇的旅游网站,一共有8个页面,包含轮播图、视频。
1.版本:matlab2022A,包含仿真操作录像和代码注释,操作录像使用windows media player播放。 2.领域:无模型自适应控制器 3.内容: 无模型自适应控制器matlab仿真。 u(k) = u(k-1)+rou*fai(k,1)*(yd(k+1)-y(k)-...
要想实现css屏幕大小自适应,首先得引入 CSS3 @media 媒体查询器: media的使用和规则: ①被链接文档将显示在什么设备上。 ②用于为不同的媒介类型规定不同的样式。 语法: @media 设备名 only (选取条件) ...
前端项目-angular-media-queries,角度服务,用于测试给定的@media语句是否为真。
手机端页面rem宽度自适应脚本 不用media属性
H5C3的易错点与@media + rem布局,以及动态图电池和旋转.zip
JavaScript依据CSS的Media Queries来推断扫瞄设备的方法_.docx
1.版本:matlab2022a,包含仿真操作录像,操作录像使用windows media player播放。 2.领域:自适应滤波。 3.内容:基于LMS算法的自适应滤波matlab仿真。LMS算法在自适应滤波器中的实现,matlab2021a运行测试。...
CSS判断不同分辨率浏览器(显示屏幕)显示不同宽度布局CSS3技术支持IE6到IE8。将用到css3 @media样式进行判断,但IE9以下版本不支持CSS3技术,这里DIVCSS5给大家介绍通过JS实现低版本的浏览器也支持CSS3实现实用布局