link标签引入,写在link标签中,有条件的引入外部样式表
index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="css-1.css">
<link rel="stylesheet" href="css-2.css"
media="(min-width:400px)">
<link rel="stylesheet" href="css-3.css"
media="(min-width:300px) and (max-width:399px)">
</head>
<body>
<div class="div0">
<div></div>
<div></div>
<div></div>
</div>
</body>
</html>
css-1.css:
.div0{
width:100%;
height:500px;
border:1px solid #ccc;
}
/* 子div浮动一行显示 */
.div0 div{
float:left;
height:200px;
}
.div0 div:nth-child(1){
background-color: red;
}
.div0 div:nth-child(2){
background-color: green;
}
.div0 div:nth-child(3){
background-color: blue;
}
css-2.css:
/* 一行显示3个div */
.div0 div{
width: 33.3%;
}
css-3.css:
.div0 div{
width: 50%;
}