CSS 结构化伪类

21 篇文章 1 订阅
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>伪类--结构化伪类</title>
<link href="css/style.css" rel="stylesheet" type="text/css"/>
<!--结构化伪类-->
<!--结构化伪类选择器如下:
	Selector:root :匹配文档的根元素。在HTML文档中,根元素永远是<html>元素
	Selector:first-child : 表示一组同胞元素中的第一个元素。
    Selector:last-child  : 表示一组同胞元素中的最后一个元素。
    Selector:nth-child(n)  : 表示一组同胞元素中的第n个元素。(顺数第n个)
    Selector:nth-last-child(n)  : 表示一组同胞元素中的倒数第n个元素。(倒数第n个)
    
    Selector:only-child : 匹配符合Selctor选择器,而且必须只有一个子节点。 
    还有其他的几个结构化选择器:和上面的类似
    Selector:first-of-type 
    Selector:last-of-type 
    Selector:nth-of-type(n)
    Selector:nth-last-of-type(n)
 	Selector:empty
-->
</head>

<body>
    <ul>
    	<li>HTML</li>
        <li>CSS</li>
        <li>JavaScript</li>
        <li>jQuery</li>
        <li>Csharp</li>
        <li>Java</li>
        <li>Andriod</li>
    </ul>
   <ul>
    	<li>MATH</li>
    </ul>
    
</body>
</html>
@charset "utf-8";
/* CSS Document */
/*:root{
	color:#900;
}
*/
li:first-child{
	color:yellow;
}
li:last-child{
	color:#60C;
}
li:nth-child(2){
	color:#2326C4;
}
li:nth-last-child(3){
	color:#2326C4;
}
li:first-of-type{
	color:yellow;
}
li:last-of-type{
	color:#60C;
}
li:nth-of-type(3){
	color:#2326C4;
}
li:nth-last-of-type(3){
	color:#2326C4;
}
li:only-child{
	color:#900;
}

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ClementQL

机会只属于对自己更狠的人。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值