css link @import

来源:互联网 发布:游戏同步器软件 编辑:程序博客网 时间:2024/05/21 09:08

if you use in html :

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>Title</title>    <style>    @import url("css1.css");    </style></head><body>    <script>        document.querySelector('body').setAttribute('background','red');    </script></body></html>

or in other css file

//css2.css@import "css1.css";//css1.cssbody{    background: green;}

Note:
.1 In some case , @import is the same to link , but @import will load after the document render , so maybe short white time , when use @import .

.2 Use @import can make css module , but use @import “css1.css” in css2.css will cause two http request :

.3 when you use @import xx.css in sass file you after compile will get same file like @import url(‘xx.css’) but compile the css code to the file that use import.

这里写图片描述

2 0
原创粉丝点击