Conditional import of CSS files

Source: Internet
Author: User

Solution 1: use conditional import in HTML documents. For example, insert the following code into the HEAD:

   1:          <!--[if IE 6]>
   2:          <link rel="stylesheet" href="ie.css" type="text/css" />
   3:          <![endif]-->
   4:          <!--[if IE]>
   5:                      <link type="text/css" media="screen" rel="stylesheet" href="js/colorbox-custom-ie.css" title="Cleanity" />
   6:          <![endif]-->

 

Solution 2: Use conditional import at the beginning of the CSS document, as shown in the following code:

   1:  [if SafMob] @import('iphone.css');   
   2:  [if ! SafMob] @import('non-iphone.css');

 

The order in which the browser loads css:
1. Load the html page specified by the url
2. parse html
3. Remotely retrieve the css file referenced by the link tag
4. Load the obtained css file and obtain the xx.css file remotely when the @ import url ("xx.css" example code is used.
5.20.execute xx.css


You can use @ import to import up to 31 CSS files. Since each remote access to css files produces an http link, it is time-consuming. Therefore, it is best to use @ import as little as possible. 31, it is estimated that no project will use so much.

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.