CSS references little-known media queries, and css references little-known

Source: Internet
Author: User

CSS references little-known media queries, and css references little-known

Media queries allow us to set appropriate styles based on various features of the device.

The following code is used:

<link rel="stylesheet" media="screen and (orientation:portrait)" href="portrait-screen.css"/>

Reference a similar table. Media attributes.

First, the media query expression asks about the media type (Are you a display screen ?), Then I asked about the media features (is the display Vertically Placed ?). Any vertically placed display device is loaded

Portrait-screen.css style sheet, which is ignored by other devices.

If not is appended at the beginning of a media query, the query logic is reversed.

For example

<link rel="stylesheet" media="not screen and (orientation:portrait)" href="portrait-screen.css"/>
It can also be used like this,

Only display devices with a display width greater than 800 pixels can load files.

<link rel="stylesheet" media="not screen and (orientation:portrait) and (min-width:800px)" href="portrait-screen.css"/>

Extended to the depth, you can use commas to represent or operations, as long as one of them is satisfied.


Of course, apart from media queries, they can be used not only to reference css style sheets, but also to style sheets.

@media screen and (max-device-width:400px){h1{color:green}}@media screen and (max-device-width:960px){h1{color:red}}

In addition, the @ import command is used to reference other style sheets in the current style sheet in the css style sheet. For example

@ Import url ("phone.css") screen and (max-width: 360px)

But remember that the @ import method of css will increase the HTTP request (this will affect the loading speed), so please use this method with caution.


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.