僞類選擇器通常會用在超連接a標籤中,使用a標籤的僞類選擇器,咱們必定要遵循"愛恨準則" LoVe HAtecss
/*沒有被訪問的a標籤的樣式*/
.box ul li.item1 a:link{
color: #666;
}
/*訪問事後的a標籤的樣式*/
.box ul li.item2 a:visited{
color: yellow;
}
/*鼠標懸停時a標籤的樣式*/
.box ul li.item3 a:hover{
color: green;
}
/*鼠標摁住的時候a標籤的樣式*/
.box ul li.item4 a:active{
color: yellowgreen;
}
再給你們介紹一種css3的選擇器nth-child()css3
/*選中第一個元素*/
div ul li:first-child{
font-size: 20px;
color: red;
}
/*選中最後一個元素*/
div ul li:last-child{
font-size: 20px;
color: yellow;
}
/*選中當前指定的元素 數值從1開始*/
div ul li:nth-child(3){
font-size: 30px;
color: purple;
}
/*n表示選中全部,這裏面必須是n, 從0開始的 0的時候表示沒有選中*/
div ul li:nth-child(n){
font-size: 40px;
color: red;
}
/*偶數*/
div ul li:nth-child(2n){
font-size: 50px;
color: gold;
}
/*奇數*/
div ul li:nth-child(2n-1){
font-size: 50px;
color: yellow;
}
/*隔幾換色 隔行換色
隔4換色 就是5n+1,隔3換色就是4n+1
*/
div ul li:nth-child(5n+1){
font-size: 50px;
color: red;
}