CSS 边框 示例代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>CSS Border Examples</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 20px;
            display: flex;
            flex-direction: column;
            gap: 20px; /* 组件间的间距 */
        }
        .solid-border {
            width: 200px;
            height: 100px;
            border: 5px solid black; /* 实线边框 */
            text-align: center;
            line-height: 100px; /* 垂直居中文本 */
        }
        .dashed-border {
            width: 200px;
            height: 100px;
            border: 5px dashed red; /* 虚线边框 */
            text-align: center;
            line-height: 100px;
        }
        .rounded-corners {
            width: 200px;
            height: 100px;
            border: 5px solid blue;
            border-radius: 15px; /* 圆角边框 */
            text-align: center;
            line-height: 100px;
        }
        .multiple-borders {
            width: 200px;
            height: 100px;
            border: 3px solid green;
            box-shadow: 0 0 0 10px orange; /* 使用阴影模拟多层边框 */
            text-align: center;
            line-height: 100px;
        }
        .gradient-border {
            width: 200px;
            height: 100px;
            position: relative;
            text-align: center;
            line-height: 100px;
        }
        .gradient-border::before {
            content: '';
            position: absolute;
            top: -10px;
            left: -10px;
            right: -10px;
            bottom: -10px;
            background: linear-gradient(45deg, #FFEB3B, #FF5722);
            z-index: -1;
            border-radius: 15px;
        }
    </style>
</head>
<body>
    <div class="solid-border">实线边框</div>
    <div class="dashed-border">虚线边框</div>
    <div class="rounded-corners">圆角边框</div>
    <div class="multiple-borders">多重边框</div>
    <div class="gradient-border">渐变边框</div>
</body>
</html>