zoukankan      html  css  js  c++  java
  • 媒体查询

    媒体查询  Media Queries

    基本的使用方法:

    一、最大宽度Max Width

      <link rel="stylesheet" media="screen and (max-600px)" href="small.css" type="text/css" />

    上面表示的是:当屏幕小于或等于600px时,将采用small.css样式来渲染Web页面。

    二、最小宽度Min Width

       <link rel="stylesheet" media="screen and (min-900px)" href="big.css" type="text/css"  />

    上面表示的是:当屏幕大于或等于900px时,将采用big.css样式来渲染Web页面。

    三、多个Media Queries使用

       <link rel="stylesheet" media="screen and (min-600px) and (max-900px)" href="style.css" type="text/css" />

    Media Query可以结合多个媒体查询,换句话说,一个Media Query可以包含0到多个表达式,表达式又可以包含0到多个关键字,以及一种Media Type。

    正如上面的其表示的是当屏幕在600px-900px之间时采用style.css样式来渲染web页面。

    四、设备屏幕的输出宽度Device Width

       <link rel="stylesheet" media="screen and (max-device- 480px)" href="iphone.css" type="text/css" />

    上面的代码指的是iphone.css样式适用于最大设备宽度为480px,比如说iPhone上的显示,这里的max-device-width所指的是设备的实际分辨率,也就是指可视面积分辨率

    五、iPhone4

       <link rel="stylesheet" media="only screen and (-webkit-min-device-pixel-ratio: 2)" type="text/css" href="iphone4.css" />

    上面的样式是专门针对iPhone4的移动设备写的。

    六、iPad

      <link rel="stylesheet" media="all and (orientation:portrait)" href="portrait.css" type="text/css" />

      <link rel="stylesheet" media="all and (orientation:landscape)" href="landscape.css"  type="text/css" />

    在大数情况下,移动设备iPad上的Safari和在iPhone上的是相同的,只是他们不同之处是iPad声明了不同的方向,比如说 上面的例子,在纵向(portrait)时采用portrait.css来渲染页面;

    在Media Query中如果没有明确指定Media Type,那么其默认为all,如:

      <link rel="stylesheet" media="(min- 701px) and (max- 900px)" href="medium.css" type="text/css" />

    另外还有使用逗号(,)被用来表示并列或者表示或,如下

      <link rel="stylesheet" type="text/css" href="style.css" media="handheld and (max-480px), screen and (min-960px)" />

    上面代码中style.css样式被用在宽度小于或等于480px的手持设备上,或者被用于屏幕宽度大于或等于960px的设备上。

    经常看到的断点值是:320px、480px、768px和1024px等。

    media的语句中包含的内容:

    1、screen:这个不用说大家都知道,指的是一种媒体类型;

    2、and:被称为关键词,与其相似的还有not,only,稍后会介绍;

    3、(max-600px):这个就是媒体特性,说得通俗一点就是媒体条件。

     原文:http://www.cnblogs.com/asqq/archive/2012/04/13/2445912.html

  • 相关阅读:
    基于udp简单聊天的系统
    网络编程_tcp与dup协议简单应用
    logging_modules
    linux内核配置与编译
    linux内核简介
    对于国嵌上学期《一跃进入C大门》Mini2440的代码修正
    通过按键玩中断
    MMU功能解析、深入剖析、配置与使用
    C与汇编混合编程
    一跃进入C大门
  • 原文地址:https://www.cnblogs.com/hilxj/p/6796099.html
Copyright © 2011-2022 走看看