标签:
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>无标题文档</title> <style> p{height:30px;border:1px solid #000;} body *:nth-child(1){margin-left:10px;}/* 无论何种类型都选择第一个 */ p:nth-child(1){color:#fff;} p:first-child{padding:20px;} p:nth-last-child(1){color:#fff;} p:last-child{padding-left:20px;} p:nth-child(odd){background:red;} p:nth-child(even){background:blue;} h2:nth-of-type(2){background: green;} p:nth-last-of-type(3){color:#999;} h3:first-of-type{color:pink;} h2:last-of-type{color:#fff;} p:empty{height:40px;border:10px solid green;} p *:only-child{border:10px dashed pink;} p *:only-of-type{border:10px dashed pink;} </style> </head> <body> <p>p1</p> <h1>h1</h1> <p>p2</p> <h2>h2</h2> <p>p3</p> <h3>h3</h3> <p>p4</p> <h2>h222</h2> <p>p5</p> <p></p> <p><span>123</span></p> <p><span>123</span><a>456</a></p> </body> </html>
E:empty 表示E元素中没有子节点。注意:子节点包含文本节点
标签:
原文地址:http://www.cnblogs.com/slp-qm/p/5236591.html