<!DOCTYPE html> <!--选择器-选择器详解(1)--> <html> <head lang="en"> <meta charset="UTF-8"> <link href="css01.css" type="text/css" rel="stylesheet"> <title></title> </head> <body> <p>人的生命是有限的</p> <h1>标题1</h1> <h2>标题2</h2> <div class="iclass">我要测试div</div> <a class="iclass">我要测试a.iclass</a> <p class="p1">我的p1</p> <p class="p2">我的p2</p> <p class="p1 p2">我的p3</p> </body></html>
css:
/*1元素选择器*/ p{ font-size: 45px; color: #b3d4fc; } /*2选择器的分组*/ h1,h2{ font-size: 45px; } /*3通配符,没有指定的,都由通配符指定*/ *{ color: blueviolet; padding: 0px; margin: 0px; } /*类选择器,class值可以重复。id不能重复*/ .iclass{ color: #ffff00; } /*类选择器,结合元素使用*/ a.iclass{ font-size: 50px; color: brown; } .p1{ font-size: 30px; } .p2{ color: #cccccc; } /*多类选择器,既有p1,p2的效果,也有自己的效果*/ .p1.p2{ font-style: inherit; }