IPhone4
<link rel= "stylesheet" media= "only screens and (-webkit-min-device-pixel-ratio:2)" type= "Text/css" href= " Iphone4.css "/>
The above style is written specifically for IPhone4 mobile devices.
Pad
<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"/>
In the case of large numbers, the safari on the mobile device is the same as on the iphone, but the difference is that the ipad declares a different direction, such as the example above, which uses PORTRAIT.CSS to render the page in Portrait (portrait);
Use LANDSCAPE.CSS to render the page in landscape (landscape).
Android
Width of/*240px */
<link rel= "stylesheet" media= "only screens and (max-device-width:240px)" href= "Android240.css" type= "Text/css"/>
Width of/*360px */
<link rel= "stylesheet" media= "only screens and (min-device-width:241px) and (max-device-width:360px)" href= " Android360.css "type=" Text/css "/>
Width of/*480px */
<link rel= "stylesheet" media= "only screens and (min-device-width:361px) and (max-device-width:480px)" href= " Android480.css "type=" Text/css "/>
We can use media query to provide specific styles for Android phones at different resolutions, so that the screen resolution can be resolved differently for Android phone page refactoring issues.
Not keyword
<link rel= "stylesheet" media= "not print and (max-width:1200px)" href= "Print.css" type= "Text/css"/>
The NOT keyword is used to exclude a certain type of media, in other words, to exclude devices that match an expression.
only keyword
<link rel= "stylesheet" media= "only screens and (max-device-width:240px)" href= "Android240.css" type= "Text/css"/>
Only used to set a specific media type that can be used to exclude browsers that do not support media queries. In fact, only many times it is used to hide style sheets for devices that do not support media query but support media type.
The main features are: devices that support media Queries, the normal invocation style, when only does not exist, and for devices that do not support media features (media Queries) but that support the medium type, which will not read the style,
Because its first reads only instead of screen, and the browser does not support media qqueries, the style will not be adopted, whether or not it supports only.
Other
If media Type is not explicitly specified in media query, it defaults to all, such as:
<link rel= "stylesheet" media= "(min-width:701px) and (max-width:900px)" href= "Medium.css" type= "Text/css"/>
There is also a comma (,) that is used to denote a juxtaposition or representation or, as follows
<link rel= "stylesheet" type= "Text/css" href= "Style.css" media= "handheld and (max-width:480px), screen and (min-width : 960px) "/>
The style.css style in the code above is used on a handheld device with a width less than or equal to 480px, or on a device with a screen width greater than or equal to 960px.
The output width of the device's screen is device width
<link rel= "stylesheet" media= "screen and (max-device-width:480px)" href= "Iphone.css" type= "Text/css"/>
The above code refers to the IPHONE.CSS style for the maximum device width of 480px, such as the display on the iphone, where Max-device-width refers to the actual resolution of the device, that is, the visual area resolution
Multiple Media queries use
<link rel= "stylesheet" media= "screen and (min-width:600px) and (max-width:900px)" href= "Style.css" type= "text/css"/ >
Media query can combine multiple media queries, in other words, a media query can contain between 0 and more expressions, and the expression can contain between 0 and more keywords, as well as a media Type.
As it says above, when the screen is between 600px-900px, the STYLE.CSS style is used to render the Web page.
One, max width max
<link rel= "stylesheet" media= "screen and (max-width:600px)" href= "Small.css" type= "Text/css"/>
The above indicates that when the screen is less than or equal to 600px, the Web page is rendered in the Small.css style.
@media Introduction
This type of introduction is the same as @import, and there are two ways:
Used in style files:
- @media screen{
- Selector {
- attribute: property value;
- }
- }
Called in <style>...</style> in
- <HEAD>
- <style type = "text/css" >
- @media Screen{
- selector {
-
- Span class= "pun" >
- }
- </STYLE>
- </HEAD>
@import approach introduced
@import introduced in two ways, one is to call a style file through @import in the style file, another method is introduced in
Another style file is called in the style file:
- @import url("Css/reset.css") screen;
- @import url("Css/print.css") print;
Called in <style>...</style> in
- <style type="Text/css">
- @import url("Css/style.css") all;
- </style>
XML approach introduced
- <? XML-stylesheet rel="stylesheet" Media="screen" href="css/ Style.css " ? >
The link method introduces
- <link rel="stylesheet" type="text/css" href=". /css/print.css " Media=" print " />
Media queries Detailed