zoukankan      html  css  js  c++  java
  • css3 -- 伪类与伪元素

    伪类:

    1、结构伪类

    A:E : first-child{}

         E : nth-*(n){}

         E : first-*(even){}

       E : first-*(odd){}

    B:nth-child 是根据其父元素中国子元素的总数进行计算

         nth-of-type 是根据特定类型的子元素进行计数

         nth-last-child 与nth-child类似,不过是从最后开始计算

         nth-last-of-type 与nth-of-type 类似,不过是从最后开始计算

    C:first-of-type 、last-child、last-of-type区别于nth-child与nth-of-type类似,是相对于特定元素或相对于父元素的第一个元素或最后一个元素

    D:only-child :有一个父元素,但没有任何的兄弟元素

         only-of-type : 没有相同类型的兄弟元素

    2、target伪类

    在涉及的URI呗使用的时候,将样式应用到元素中

    3、empty伪类

    选择没有子元素(包含文本节点)的元素

    4、root伪类

    选择文档树中的第一个元素,在HTML中,root永远是html元素,使用root可以将html元素赋予更高的特殊度

    5、not伪类

    E:not(F){}  选择除了作为参数值给出的元素之外的所有元素

    传入not伪类的参数都必须是一个简单选择器

    伪元素:

    1、CSS2中:

    :first-line

    :first-letter

    :after

    :before

    2、CSS3中,没有添加新的伪元素,但对伪元素的定义稍微进行了优化

    ::first-line

    ::first-letter

    ::after

    ::before

    3、::selection 选择器匹配被用户选取的选取部分

    1 p::selection {
    2    color:white;
    3 }

    Opera以及Webkit已经实现了,Firefox通过前缀实现

    以上伪类以及伪元素要考虑IE8

  • 相关阅读:
    Ruby:Hash 排序
    Rails bug: ROR + A server is already running. Check …/tmp/pids/server.pid. Exiting
    MySQL 删除数据的最好的方式
    FATAL ERROR: The persistent cache of section information does not match the current configu...
    http和https的区别
    SAP BusinessObject < Aggregate Navigation >
    BO Server Session Setting
    BusinessObject Port 配置
    重复提交
    FCKeditor
  • 原文地址:https://www.cnblogs.com/zhanghuiyun/p/5528884.html
Copyright © 2011-2022 走看看