CSS选择器

来源:互联网 发布:为什么python安装失败 编辑:程序博客网 时间:2024/06/06 23:20
对于同样的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