CSS Media Query
【CSS Media Query】
CSS Media Queries are a feature in CSS3 which allows you to specify when certain CSS rules should be applied. This allows you to apply a special CSS for mobile, or adjust a layout for print.
The basic syntax looks like this:
// normal style
#header-image {
background-repeat: no-repeat;
background-image:url('image.gif');
} // show a larger image when you're on a big screen
@media screen and (min-width: 1200px) {
#header-image {
background-image:url('large-image.gif');
}
} // remove header image when printing.
@media print {
#header-image {
display: none;
}
}
But can also be called like this:
<link rel='stylesheet' media='all' href='normal.css' />
<link rel='stylesheet' media='print' href='print.css' />
<link rel='stylesheet' media='screen and (min-width: 701px)' href='medium.css' />
The advantage of this method is that only the valid CSS is downloaded; so no print.css is only downloaded when printing (or using print preview).
This example shows the 2 blocks on big screens next to each other, while on small screens they will be displayed below each other.
#block1, #block2 {
float: left;
width: 100%;
}
@media (min-width: 1000px) {
#block1, #block2 {
width: 50%;
}
}
参考:http://cssmediaqueries.com/what-are-css-media-queries.html
CSS Media Query的更多相关文章
- mobile adaptor & css media query
mobile adaptor & css media query 移动端适配 & 媒体查询 http://cssmediaqueries.com/ device-aspect-rati ...
- css Media Query详解
Media Queries详解 Media Queries直译过来就是“媒体查询”,在我们平时的Web页面中head部分常看到这样的一段代码: 1 <link href="css/re ...
- CSS media query应用中的层叠特性使用最佳实践
media query是css3规范中引入的,它提供了一种responsive design的基础机制:浏览器在不同size的设备中将以不同样式展现网页,这就给一个网页能够适应不同device一种可能 ...
- iPhone CSS media query(媒体查询)
iPhone5 iPhone6 iPhone6Plus iPad设备 media query(媒体查询)代码. iPhone < 5: @media screen and (device-a ...
- 一些实用的CSS Media Query代码片段,个人采集
CSS3的出现让响应式Web设计变得简单,CSS3提供了强大的media queries,允许你针对不同的条件设置不同的样式,可以在不修改页面内容的情况下,为不同设备提供不同的样式效果. 以下是一些C ...
- CSS media queries
最近在做一些页面打印时的特殊处理接触到了media queries,想系统学习一下,在MOZILLA DEVELOPER NETWORK看到一篇文章讲的很不错,结合自己的使用总结一下. CSS2/me ...
- 采用CSS3 Media Query技术适应Android平板屏幕分辨率和屏幕像素密度
采用HTML5在开发移动应用程序满足各种需求Android分辨率和屏幕的平板设备密度,这是非常麻烦的过程,最终的解决方案是使用css media query,匹配相同的时间分辨率和屏幕像素密度.上进行 ...
- 脚本检测 media query 分界点
当需要为不同屏幕大小添加不同脚本的时候,首先需要检测对应的media query 是否起效 也就是CSS( @screen only and (min-width: 40em) {})和javascr ...
- 响应式设计的思考:媒体查询(media query)
Jason Grigsby发表了篇文章,<CSS Media Query for Mobile is Fool’s Gold>对媒体查询(media query)吐槽,大意是在移动设备上使 ...
随机推荐
- <项目管理的决策力>总结梳理
最近去总部参加了两天培训,关于<项目管理的决策力>,有时间会整理一下思路. ---todo 总结 6个阶段30个决策点如下:
- 关于lampp中的proftpd的一些使用
这个是配置文件 ServerName "ProFTPD" ServerType standalone DefaultServer on Port 21 这个是端口 Umask Ma ...
- C#内存管理和垃圾回收机制
数据类型 垃圾回收机制 一.数据类型 C#中的数据类型分为值类型 (Value type) 和引用类型(reference type), 值 类 型: 所有的值类型都集成自 System.Value ...
- C# 趣味小程序(4)——遍历特定目录及其子目录
//递归方法遍历目录,并统计其中文件的数目 private int statisticFiles(string directory) { int st ...
- Ubuntu系统安装
一:Ubuntu14.04 安装及使用:[1]制作安装U盘(选择USB-HDD+”并单击后, 一定要点“写入”,注意,“写入”是一个按钮) 以下是详细的连接步骤: https:// ...
- Linux sed 流编辑器
sed是stream editor的简称,也就是流编辑器.盗用一张图片解释原理 命令格式: SYNPPSIS: sed [OPTION]… {script-only-if-no-other-scrip ...
- MVC控制器返回重定向操作
注意:在使用Ajax请求后台时是不能在后台重定向的! 解决方案: if (userInfoService.CheckUser(username, psd, out msg)) { , msg = &q ...
- 玩转音频、视频的利器:FFmpeg
导语 当下直播平台发展十分迅猛,依靠游戏内直播平台的发展带动游戏活跃提升收入,那么对于我们开发来说如何玩转视频呢?下面就来介绍一个音频.视频处理利器——FFmpeg. FFmpeg 简介 FFmpeg ...
- mfc cef<转>
在mfc单文档程序中加入cef: .在BOOL CtestCEFApp::InitInstance()中初始化cef HINSTANCE hInst = GetModuleHandle(NULL); ...
- 2018SDIBT_国庆个人第四场
A - A 这题很巧妙啊,前两天刚好做过,而且就在博客里 Little C Loves 3 I time limit per test 1 second memory limit per test ...