css中的伪类::before和::after用法

效果图:


:一个冒号是css的过时用法
::两个冒号是css3的用法

<!DOCTYPE html>
<html lang="en">
    <style>
        h2::before {/*一个:是css过时语法的,2个:是CSS3语法/
            /* content: 'hi'; */
            content: '';
            color: palegreen;
            width: 200px;
            margin: 8px;
            display:inline-block;
            border: 1px solid rebeccapurple
        }
        h2::after {
            content: '';
            color: palegreen;
            width: 200px;
            margin: 8px;
            display:inline-block;
            border: 1px solid rebeccapurple
        }
    </style>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h2>精品选购</h2>
</body>
</html>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。