zoukankan      html  css  js  c++  java
  • 05-伪类选择器

    伪类选择器一般会用在超链接a标签中,使用a标签的伪类选择器,我们一定要遵循"爱恨准则"  LoVe HAte

     1               /*没有被访问的a标签的样式*/
     2         .box ul li.item1 a:link{
     3             
     4             color: #666;
     5         }
     6         /*访问过后的a标签的样式*/
     7         .box ul li.item2 a:visited{
     8             
     9             color: yellow;
    10         }
    11         /*鼠标悬停时a标签的样式*/
    12         .box ul li.item3 a:hover{
    13             
    14             color: green;
    15         }
    16         /*鼠标摁住的时候a标签的样式*/
    17         .box ul li.item4 a:active{
    18             
    19             color: yellowgreen;
    20         }
    View Code

    再给大家介绍一种css3的选择器nth-child()

                  /*选中第一个元素*/
            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;
            }
                
    View Code
  • 相关阅读:
    Java多线程之Exchanger
    Java8 比AtomicLong更加高效的原子操作LogAdder
    synchronized父子类对象锁重入
    java8 stream多字段排序
    利用java代码给mongo数据库加索引、删除索引等操作
    C++之IO
    C++之类的定义和性质
    C++之动态内存与类型转换
    C++之字符与其他数据类型
    C++之函数与模板
  • 原文地址:https://www.cnblogs.com/majj/p/9026610.html
Copyright © 2011-2022 走看看