css实习三色交替背景

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        p:nth-child(3n-2) {
            background:#ff0000;
        }
        p:nth-child(3n-1) {
            background:#0000ff;
        }
        p:nth-child(3n) {
            background:green;
        }
    </style>
</head>
<body>
<p>x</p>
<p>x</p>
<p>x</p>
<p>x</p>
<p>x</p>
<p>x</p>
<p>x</p>
<p>x</p>
<p>x</p>
<p>x</p>
<p>x</p>
<p>x</p>
<p>x</p>
<p>x</p>
<p>x</p>
<p>x</p>
<p>x</p>
<p>x</p>
<p>x</p>
</body>
</html>
posted @ 2022-05-18 08:52  fly_bk  阅读(87)  评论(0编辑  收藏  举报