Import CSS files using judgment conditions

Import CSS files using judgment conditions

Solution 1: Use conditional import in HTML document, such as inserting the following code in HEAD:

Copy code
The code is as follows:

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

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

Copy code
The code is as follows:

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

The order in which the browser loads CSS:
1. Load the HTML page specified by the URL
2. Parsing HTML
3. Remotely obtain the css file referenced by the link tag
4. Load and execute the obtained css file. When encountering the code @import url("xx.css"), xx.css will be obtained remotely.
5. Load and execute xx.css
You can import up to 31 CSS files through @import. Since each remote retrieval of a CSS file will generate an http link, it is time-consuming, so it is best to use @import as little as possible. 31. I don’t think any project will use so many.

<<:  Hbase installation and configuration tutorial under Linux

>>:  If I change a property randomly in Vue data, will the view be updated?

Recommend

How to use HTML+CSS to create TG-vision homepage

This time we use HTML+CSS layout to make a prelim...

Install MySQL 5.7.18 using rpm package under CentOS 7

I have been using MySQL recently. The article mys...

Web design dimensions and rules for advertising design on web pages

1. Under 800*600, if the width of the web page is...

How to deploy redis in linux environment and install it in docker

Installation Steps 1. Install Redis Download the ...

JavaScript to achieve accordion effect

This article shares the specific code for JavaScr...

How to install MySQL 8.0 and log in to MySQL on MacOS

Follow the official tutorial, download the instal...

Understanding v-bind in vue

Table of contents 1. Analysis of key source code ...

Summary of some common methods of JavaScript array

Table of contents 1. How to create an array in Ja...

WeChat applet date and time component (year, month, day, hour, and minute)

This article example shares the specific code of ...

JavaScript implements page scrolling animation

Table of contents Create a layout Add CSS styles ...

Vue practice of preventing multiple clicks

Generally, click events will be divided into diff...

Windows 2019 Activation Tutorial (Office2019)

A few days ago, I found that the official version...

Detailed explanation of the principle and usage of MySQL views

This article uses examples to illustrate the prin...

HTML+jQuery to implement a simple login page

Table of contents Introduction Public code (backe...