Use of @media

Source: Internet
Author: User

[Email protected] rules

1.1 Media Type:

all: match all devices;

handle: Matching handheld devices (small screen, monochrome, limited bandwidth);

Print: matches the screen in paged media or print preview mode;

Screen : matching Color computer screens;

Other media types are Braille(Braille tactile feedback device),embossed(Braille paging printer),projection(projector),speech(Speech synthesizer ),TTY(fixed-width character grid devices such as telephone screens), and TVs(TVS).

Learn more about the CSS2.1 standard

1.2 Common media Features:

Min-device-width and Max-device-width: match the size of the device screen;

Min-width and Max-width: matches the width of the viewport, such as the browser width;

Orientation (Value portrait and landscape): whether the matching device is a horizontal or vertical screen.

1.3 Logical operations: And , not, or

1.4 Keywords:all, only

Media Properties for 2.<link> tags

You can choose to load the style sheet by using the Media property in the link tag.

<type= "Text/css"  media= "print"  href= "Css/print _style.css "/><type=" Text/css "  Media = "screen and (max-width:568px)" href = "Css/iphone_style.css" />

3. Breakpoints

@media screen and   (max-width:640px) /* CSS Rules */}

Personally, you don't want to set a style for a particular device, but to set it up when you find the style is inappropriate.

Andriod, iOS, and Windows device media queries

Media Literacy Text

4. into Devicepixelratio:

Devicepixelratio refers to Window.devicepicelratio.

Devicepixelratio = physical pixel/device independent pixels.

Non-Retina screen device, window.devicepixelratio=1.

Actual test

4.1. Browser

The Chrome browser on my Computer (version 51.0.2704.106 m), pops up 1:

FF Browser (48.0.2):

4.2.IOS

No retinal devices were 1, and retinal devices were 2.

4.3.Android no fixed value

Summarize:

iOS device: screen.width * devicepixelratio = physical pixels.

Andriod:screen.width/devicepicelratio = device independent pixels.

Use of @media

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.