css的常用选择器
1:通用选择器
*{body:margin:0; herght:0;}
用这个选择器会给浏览器增加很大的加载负担,还会掉网站权重,我个人已经抛弃使用
浏览器兼容性:IE6+ Firefox Chrome Safari Opera
2:ID选择器
/**在css里写入id名**/
<style type="text/css">
#wrap{
margin:0; herght:0;
}
{/style}
/**在body里设置id名**/
<body>
<div id="wrap">
</div>
</body>
这个选择器我只在重要区域使用,因为id名字只能出现一次,而我是出了名的起名困难户
浏览器兼容性:IE6+ Firefox Chrome Safari Opera
3.class类别选择器
/**在css里写入类名**/
<style type="text/css">
.wrap{
margin:0; herght:0;
}
{/style}
/**在body里设置id名**/
<body>
<div class="wrap">
</div>
<div class="wrap">
</div>
<div class="wrap">
</div>
</body>
类选择器的开头用.(点)进行表示。与ID选择器的区别就是可以重用。及选中所有class命名的元素,都是di选择器的权重大于class选择器,当css里的元素里有两个名字时,只会解析id选择器
浏览器兼容性:IE6+ Firefox Chrome Safari Opera