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

Detailed tutorial for installing ElasticSearch:7.8.0 cluster with docker

ElasticSearch cluster supports動態請求的方式and靜態配置文件to ...

Summary of basic knowledge and operations of MySQL database

This article uses examples to explain the basic k...

Several ways to implement image adaptive container with CSS (summary)

There is often a scenario where the image needs t...

Mysql implements three functions for field splicing

When exporting data to operations, it is inevitab...

Use nginx to dynamically convert image sizes to generate thumbnails

The Nginx ngx_http_image_filter_module module (ng...

Docker data management and network communication usage

You can install Docker and perform simple operati...

Installation and configuration method of Zabbix Agent on Linux platform

Here is a brief summary of the installation and c...

Tips for List Building for Website Maintenance Pages

And, many times, maintenance requires your website...

HTML form tag tutorial (2):

This tutorial introduces the application of vario...

Detailed process of FastAPI deployment on Docker

Docker Learning https://www.cnblogs.com/poloyy/p/...

MySQL 8.0.21 installation and configuration method graphic tutorial

Record the installation and configuration method ...

Detailed explanation of the two modes of Router routing in Vue: hash and history

hash mode (default) Working principle: Monitor th...

How to import CSS styles into HTML external style sheets

The link-in style is to put all the styles in one...