CSS伪类、伪元素选择器

来源:互联网 发布:淘宝主店铺旺旺怎么找 编辑:程序博客网 时间:2024/05/16 01:21

1 伪类选择器

条件一:根据元素不同的状态,自动选择不同的样式

first-child

a:hover鼠标划过的时候添加样式

a:active鼠标点击的时候添加样式,

a:link链接地址未被访问时候添加,必须设置href属性

a:visite链接地址已经被访问的时候添加样式,必须设置href属性

<style type="text/css">
        a{
            text-decoration:none;
        }
      /*  a:hover{
            text-decoration: underline;
            font-size: 30px;
       }*/
       /* a:active{
            color: yellow;
        }*/
        /*a:link{
            color: yellow;
        }*/
       /* a:visited{
            color: gray;
        }*/
     

   </style>
</head>
<body>
<a href="http://www.huadianedu99999.com/"target="_blank">华点软件学院</a>

</body>

input:focus鼠标点击输入框,背景颜色会变化。

input:focus{
    background-color: #3695ff;
}

<input tyoe="text">

2 伪元素选择器

需要设置特殊效果的内容放到一个元素(标签)里面

first-letter,选择第一个元素

first-line,选择第一行

before,在之前添加内容

after,在之后添加内容

li:after{
    content:'';
}