伪元素选择器的应用 after,before

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>伪元素选择器</title>
    <style>
        a {
            display: block;
            width: 200px;
            height: 200px;
            background-color: pink;
            line-height: 200px;
            text-align: center;
            color:#fff;
            text-decoration: none;
         
        }
        a:hover::after{
            display: block;
            width: 200px;
            height: 200px;
            background-color:deeppink;
            content: "我是后面的伪元素选择器"; /* content一定要写 可以留空  content:'' */
        }

        a:hover::before{
            display: block;
            width: 200px;
            height: 200px;
            background-color:blue;
            content: "我是前面的伪元素选择器";   /* content一定要写 可以留空  content:'' */
        }
    </style>
</head>
<body>
    <a href=""></a>
</body>
</html>

上一篇:Less-混合


下一篇:CSS(四) (盒子塌陷问题)