zoukankan      html  css  js  c++  java
  • 伪类

    1、链接伪类:

    :link

    :visited

    2、动态伪类(可应用到任何元素)

    :focus

    :hover

    :active

    伪类顺序很重要;通常建议:link-visited-focus-hover-active

    3、静态伪类

    :first-child(第一个此类元素)

     p:first-child { font-weight: bold; }
    
                li:first-child { text-transform: uppercase; }
    
    
            <p>there are not </p> <!--起作用-->
            <p>there are not </p> <!--不起作用-->
            <p>there are not </p> <!--不起作用-->
            <p>there are not </p> <!--不起作用-->
            <div>
                <p>there are</p> <!--起作用-->
                <p>there are</p>
                <ul>
                    <li>key</li> <!--起作用-->
                    <li>key</li> <!--不起作用-->
                    <li>key</li> <!--不起作用-->
                </ul>
                <p>do <em>not</em> push</p>
            </div>
            <div>
                <div>
                    <p>other div</p> <!--起作用-->
                    <p>other div</p> <!--不起作用-->
                    <p>other div</p><!--不起作用-->
                </div>
                
            </div>

     3、伪类元素选择器,设置首字母样式

    h1:first-letter {
                    color: red;
                    font-size: 200%;
                } 
    <h1>first</h1>

    设置第一行样式。

    :first-line

    所有伪元素都必须出现在该伪元素的最后面。如p:first-letter em就不合法

    4、设置之前或之后的元素

    h2:before {
                    content: "}}";color: red;
                }
    <h2>first</h2>
  • 相关阅读:
    Servlet三种实现方法(四)
    Tomcat 网站部署(三)
    MySQL表的增删改查和列的修改(二)
    Tomcat的目录结构(二)
    addEventListener,attachEvent
    DOM事件流
    函数内部的函数中的this都是指向window
    css3 translate属性
    parent,parents和closest
    each用法
  • 原文地址:https://www.cnblogs.com/tyb1222/p/4185101.html
Copyright © 2011-2022 走看看