CSS选择器

对于同样的CSS属性,选择器优先级是,id选择器>class选择器>标签名选择器。class+标签名选择器>class选择器。

对于不同的CSS属性,继承。上面优先级反走。
</pre><pre name="code" class="html"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CSS的基本选择器</title>
</head>


<style type="text/css">
h1{color:blue; font-size:25px; text-decoration:underline;}				/*标签选择器  */
em{ color:red;}																	
p span{ color:green;}
p{font-weight:normal; font-size:55px;}


.red{ color:red; font-size:55px;}						/*类选择器使用"."进行标识,后紧跟类名  */
.two{ font-weight:lighter; font-size:13px;}
.father div{ background-color:red;
.son{background-color:blue;}


#one{ font-weight:bold; font-size:36px;}        			  /*ID选择器使用“#”前缀标识符进行标识  */

}
</style>


<body>
<h1>标签名选择器</h1>
<p class="red">class选择器</p>
<p id="one">id选择器</p>
<p><span>嵌套选择器</span></p>
<h1><em>嵌套选择有继承特性</em></h1>
<p id="one" style=" font-weight:lighter; font-size:13px">行内样式>ID选择器</p>
<p id="one" class="two">ID选择器>class选择器</p>
<p class="two">class选择器>标签名选择器</p>
<div class="father">背景色为red
<div class="son">class+标签名选择器>class选择器</div>
</div>
</body>
</html>




效果图:


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值