纯css实现奥运五环

100 阅读1分钟

好了话不多说,现在带大家快速使用纯css实现奥运五环

效果展示

代码展示

<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>奥运五环</title>
    <style>
        .rings-box {
            position: relative;
            width: 400px; /* 增加容器宽度以适应间距 */
            height: 200px; /* 增加容器高度 */
            margin: 50px auto;
        }
        .ring {
            position: absolute;
            width: 100px; /* 环的直径 */
            height: 100px; /* 环的直径 */
            border: 6px solid;
            border-radius: 50%; /* 圆形 */
        }
        .ring.blue {
            border-color: blue;
            top: 0;
            left: 0;
        }
        .ring.black {
            border-color: black;
            top: 0;
            left: 120px; /* 增加间距 */
        }
        .ring.red {
            border-color: red;
            top: 0;
            left: 240px; /* 增加间距 sss*/
        }
        .ring.yellow {
            border-color: yellow;
            top: 60px; /* 增加高度以避免重叠 */
            left: 60px; /* 增加间距 */
        }
        .ring.green {
            border-color: green;
            top: 60px; /* 增加高度 */
            left: 180px; /* 增加间距 */
        }
    </style>
</head>
<body>
    <div class="rings-box">
        <div class="ring blue"></div>
        <div class="ring black"></div>
        <div class="ring red"></div>
        <div class="ring yellow"></div>
        <div class="ring green"></div>
    </div>
</body>
</html>

简单吧~作为中国人作为真正的程序员可要画出来哦~~~