关于css中的样式表冲突

代码示例如下:
<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus?">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <link rel = "stylesheet" type = "text/css" href = "b.css"></link>
 
  <link rel = "stylesheet" type = "text/css" href = "d.css"></link>
   <link rel = "stylesheet" type = "text/css" href = "c.css"></link>
  <title>样式表的冲突的解决</title>
<style type="text/css">
/*
1.行级 > 内部 > 外部
2.id > 类选择器 > 标签选择器
   外部样式表中俄id选择器 > 内部样式表的标签选择器


原则: 就近原则  (当有多个外部选择器时,
对于外部选择器,就近是指引入的哪个靠后,
当有多个类选择器时,对于类选择器,是指定义的哪个靠后)


*/
div{
color:blue ;
}


.two{
border:3px dotted green ;
color:red ;
}
.one{
color:yellow ;
}



#d{
color:green ;
}


p{
color:red ;
}
</style>
 </head>
 <body>
       <div class = "one" id = "d">大家好</div>


  <P id = "p" style = "color:blue;">哈哈哈</p>


  <h1>哈哈哈</h1>


  <h2 class = "two one" >哈哈哈</h2>
 </body>
</html>


b.css的代码如下:
div{
color:red;
}


#p{
color:yellow;
}



c.css的代码如下:
h1{
color:red ;
}



d.css的代码示例如下:
h1{
color:yellow;
}



运行结果如下:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值