今天我們來創建一個炫酷的霓虹脈衝光效邊框,它結合了霓虹燈的光效和脈衝動畫,創造出未來感十足的UI元素。這個效果使用了CSS邊框、陰影、漸變和動畫的高級技巧。

實現思路

  1. 使用多層box-shadow創建霓虹光暈效果
  2. 通過@keyframes動畫實現脈衝和流動光效
  3. 利用clip-path創建不規則邊框形狀
  4. 結合gradient背景和混合模式增強視覺效果
  5. 添加懸浮和點擊交互效果

下面是完整的實現代碼:

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>炫酷的霓虹脈衝光效邊框 - 每天一個CSS小樣式</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', 'Arial Rounded MT Bold', Arial, sans-serif;
        }
        
        body {
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background: #0a0a1a;
            color: #fff;
            padding: 20px;
            overflow-x: hidden;
            background-image: 
                radial-gradient(circle at 10% 20%, rgba(255, 0, 128, 0.05) 0%, transparent 20%),
                radial-gradient(circle at 90% 80%, rgba(0, 255, 204, 0.05) 0%, transparent 20%);
        }
        
        .header {
            text-align: center;
            margin-bottom: 50px;
            max-width: 900px;
            position: relative;
            z-index: 1;
        }
        
        h1 {
            font-size: 3.2rem;
            font-weight: 800;
            text-transform: uppercase;
            letter-spacing: 4px;
            margin-bottom: 20px;
            position: relative;
            display: inline-block;
            padding: 0 30px;
        }
        
        .title-neon {
            color: #fff;
            text-shadow: 
                0 0 5px #fff,
                0 0 10px #fff,
                0 0 20px #ff0080,
                0 0 30px #ff0080,
                0 0 40px #ff0080;
            animation: title-pulse 3s infinite alternate;
        }
        
        .title-border {
            -webkit-text-stroke: 2px #00ffcc;
            -webkit-text-fill-color: transparent;
            animation: border-pulse 4s infinite alternate;
        }
        
        .subtitle {
            font-size: 1.3rem;
            color: #a0a0d0;
            margin-bottom: 25px;
            line-height: 1.6;
            max-width: 700px;
            margin-left: auto;
            margin-right: auto;
        }
        
        .container {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
            gap: 40px;
            margin-bottom: 50px;
            max-width: 1300px;
            width: 100%;
        }
        
        .neon-card {
            background: rgba(15, 15, 35, 0.7);
            border-radius: 20px;
            padding: 40px 30px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
            position: relative;
            overflow: hidden;
            transition: transform 0.4s ease;
            backdrop-filter: blur(10px);
            z-index: 1;
        }
        
        .neon-card:hover {
            transform: translateY(-10px);
        }
        
        .card-title {
            font-size: 1.7rem;
            margin-bottom: 25px;
            color: #7aefff;
            display: flex;
            align-items: center;
            gap: 12px;
            z-index: 2;
            position: relative;
        }
        
        .card-title i {
            font-size: 1.5rem;
        }
        
        .card-desc {
            text-align: center;
            color: #b0b0e0;
            margin-bottom: 30px;
            line-height: 1.6;
            z-index: 2;
            position: relative;
        }
        
        /* 邊框樣式容器 */
        .border-container {
            width: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 200px;
        }
        
        /* 邊框1:基本霓虹脈衝邊框 */
        .border-1 {
            width: 200px;
            height: 100px;
            background: rgba(10, 10, 30, 0.8);
            border-radius: 15px;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            font-size: 1.3rem;
            font-weight: 600;
            color: #fff;
            cursor: pointer;
            transition: all 0.3s ease;
            
            /* 多層陰影創建霓虹光暈 */
            box-shadow: 
                0 0 5px #ff0080,
                0 0 10px #ff0080,
                0 0 15px #ff0080,
                0 0 20px #ff0080,
                inset 0 0 10px rgba(255, 0, 128, 0.3);
            
            /* 動畫效果 */
            animation: neon-pulse-1 2s infinite alternate;
        }
        
        .border-1::before {
            content: '';
            position: absolute;
            top: -3px;
            left: -3px;
            right: -3px;
            bottom: -3px;
            background: linear-gradient(45deg, #ff0080, #00ffcc, #ff0080, #00ffcc);
            border-radius: 18px;
            z-index: -1;
            opacity: 0;
            transition: opacity 0.5s ease;
        }
        
        .border-1:hover::before {
            opacity: 1;
            animation: border-rotate 4s linear infinite;
        }
        
        /* 邊框2:漸變流動邊框 */
        .border-2 {
            width: 200px;
            height: 100px;
            background: rgba(10, 10, 30, 0.8);
            border-radius: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            font-size: 1.3rem;
            font-weight: 600;
            color: #fff;
            cursor: pointer;
            
            /* 使用偽元素創建流動邊框 */
            overflow: hidden;
        }
        
        .border-2::before {
            content: '';
            position: absolute;
            top: -2px;
            left: -2px;
            right: -2px;
            bottom: -2px;
            background: linear-gradient(90deg, 
                #ff0080, #00ffcc, #9d00ff, #ff0080);
            background-size: 300% 100%;
            border-radius: 22px;
            z-index: -1;
            animation: gradient-flow 4s linear infinite;
        }
        
        .border-2::after {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(10, 10, 30, 0.9);
            border-radius: 18px;
            z-index: 0;
        }
        
        .border-2 span {
            position: relative;
            z-index: 1;
        }
        
        /* 邊框3:光點追逐邊框 */
        .border-3 {
            width: 200px;
            height: 100px;
            background: rgba(10, 10, 30, 0.8);
            border-radius: 15px;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            font-size: 1.3rem;
            font-weight: 600;
            color: #fff;
            cursor: pointer;
        }
        
        .border-3 .light-chase {
            position: absolute;
            top: -3px;
            left: -3px;
            right: -3px;
            bottom: -3px;
            border-radius: 18px;
            z-index: -1;
            overflow: hidden;
        }
        
        .border-3 .light-chase::before {
            content: '';
            position: absolute;
            width: 20px;
            height: 100%;
            background: linear-gradient(90deg, transparent, #00ffcc, transparent);
            animation: light-chase 2s linear infinite;
        }
        
        .border-3 .light-chase::after {
            content: '';
            position: absolute;
            width: 20px;
            height: 100%;
            background: linear-gradient(90deg, transparent, #ff0080, transparent);
            animation: light-chase 2s linear infinite;
            animation-delay: 1s;
        }
        
        /* 邊框4:像素脈衝邊框 */
        .border-4 {
            width: 200px;
            height: 100px;
            background: rgba(10, 10, 30, 0.8);
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            font-size: 1.3rem;
            font-weight: 600;
            color: #fff;
            cursor: pointer;
            
            /* 使用clip-path創建像素風格 */
            clip-path: polygon(
                0% 10px, 10px 10px, 10px 0%,
                calc(100% - 10px) 0%, calc(100% - 10px) 10px, 100% 10px,
                100% calc(100% - 10px), calc(100% - 10px) calc(100% - 10px), 
                calc(100% - 10px) 100%, 10px 100%, 10px calc(100% - 10px),
                0% calc(100% - 10px)
            );
        }
        
        .border-4::before {
            content: '';
            position: absolute;
            top: -3px;
            left: -3px;
            right: -3px;
            bottom: -3px;
            background: #00ffcc;
            z-index: -1;
            clip-path: polygon(
                0% 10px, 10px 10px, 10px 0%,
                calc(100% - 10px) 0%, calc(100% - 10px) 10px, 100% 10px,
                100% calc(100% - 10px), calc(100% - 10px) calc(100% - 10px), 
                calc(100% - 10px) 100%, 10px 100%, 10px calc(100% - 10px),
                0% calc(100% - 10px)
            );
            animation: pixel-pulse 2s infinite alternate;
        }
        
        /* 邊框5:菱形霓虹邊框 */
        .border-5 {
            width: 200px;
            height: 100px;
            background: rgba(10, 10, 30, 0.8);
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            font-size: 1.3rem;
            font-weight: 600;
            color: #fff;
            cursor: pointer;
            clip-path: polygon(10% 0%, 90% 0%, 100% 50%, 90% 100%, 10% 100%, 0% 50%);
        }
        
        .border-5::before {
            content: '';
            position: absolute;
            top: -4px;
            left: -4px;
            right: -4px;
            bottom: -4px;
            background: linear-gradient(45deg, #ff0080, #00ffcc, #ff0080);
            background-size: 200% 200%;
            clip-path: polygon(10% 0%, 90% 0%, 100% 50%, 90% 100%, 10% 100%, 0% 50%);
            z-index: -1;
            animation: gradient-shift 4s ease infinite;
        }
        
        /* 邊框6:多層光暈邊框 */
        .border-6 {
            width: 200px;
            height: 100px;
            background: rgba(10, 10, 30, 0.8);
            border-radius: 15px;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            font-size: 1.3rem;
            font-weight: 600;
            color: #fff;
            cursor: pointer;
        }
        
        .border-6::before,
        .border-6::after {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            border-radius: 15px;
            z-index: -1;
            animation: multi-glow 3s ease-in-out infinite alternate;
        }
        
        .border-6::before {
            border: 3px solid #ff0080;
            animation-delay: 0s;
        }
        
        .border-6::after {
            border: 3px solid #00ffcc;
            animation-delay: 0.5s;
        }
        
        /* 邊框7:圓點連接邊框 */
        .border-7 {
            width: 200px;
            height: 100px;
            background: rgba(10, 10, 30, 0.8);
            border-radius: 15px;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            font-size: 1.3rem;
            font-weight: 600;
            color: #fff;
            cursor: pointer;
            overflow: hidden;
        }
        
        .border-7 .dot-border {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            border-radius: 15px;
            z-index: -1;
        }
        
        .border-7 .dot {
            position: absolute;
            width: 8px;
            height: 8px;
            background: #00ffcc;
            border-radius: 50%;
            box-shadow: 0 0 10px #00ffcc;
        }
        
        .border-7 .dot:nth-child(1) { top: 5px; left: 5px; animation: dot-pulse 2s infinite; }
        .border-7 .dot:nth-child(2) { top: 5px; right: 5px; animation: dot-pulse 2s infinite 0.2s; }
        .border-7 .dot:nth-child(3) { bottom: 5px; right: 5px; animation: dot-pulse 2s infinite 0.4s; }
        .border-7 .dot:nth-child(4) { bottom: 5px; left: 5px; animation: dot-pulse 2s infinite 0.6s; }
        
        /* 邊框8:不規則光效邊框 */
        .border-8 {
            width: 200px;
            height: 100px;
            background: rgba(10, 10, 30, 0.8);
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            font-size: 1.3rem;
            font-weight: 600;
            color: #fff;
            cursor: pointer;
            clip-path: polygon(
                0% 20px, 20px 0%,
                calc(100% - 20px) 0%, 100% 20px,
                100% calc(100% - 20px), calc(100% - 20px) 100%,
                20px 100%, 0% calc(100% - 20px)
            );
        }
        
        .border-8::before {
            content: '';
            position: absolute;
            top: -3px;
            left: -3px;
            right: -3px;
            bottom: -3px;
            background: linear-gradient(45deg, #ff0080, #00ffcc, #9d00ff);
            background-size: 200% 200%;
            clip-path: polygon(
                0% 20px, 20px 0%,
                calc(100% - 20px) 0%, 100% 20px,
                100% calc(100% - 20px), calc(100% - 20px) 100%,
                20px 100%, 0% calc(100% - 20px)
            );
            z-index: -1;
            animation: irregular-glow 3s ease infinite;
        }
        
        /* 動畫定義 */
        @keyframes title-pulse {
            0%, 100% {
                text-shadow: 
                    0 0 5px #fff,
                    0 0 10px #fff,
                    0 0 20px #ff0080,
                    0 0 30px #ff0080,
                    0 0 40px #ff0080;
            }
            50% {
                text-shadow: 
                    0 0 2px #fff,
                    0 0 5px #fff,
                    0 0 10px #ff0080,
                    0 0 15px #ff0080,
                    0 0 20px #ff0080;
            }
        }
        
        @keyframes border-pulse {
            0%, 100% {
                -webkit-text-stroke: 2px #00ffcc;
            }
            50% {
                -webkit-text-stroke: 2px #ff0080;
            }
        }
        
        @keyframes neon-pulse-1 {
            0% {
                box-shadow: 
                    0 0 5px #ff0080,
                    0 0 10px #ff0080,
                    0 0 15px #ff0080,
                    0 0 20px #ff0080,
                    inset 0 0 10px rgba(255, 0, 128, 0.3);
            }
            100% {
                box-shadow: 
                    0 0 10px #ff0080,
                    0 0 20px #ff0080,
                    0 0 30px #ff0080,
                    0 0 40px #ff0080,
                    inset 0 0 20px rgba(255, 0, 128, 0.5);
            }
        }
        
        @keyframes border-rotate {
            0% {
                transform: rotate(0deg);
            }
            100% {
                transform: rotate(360deg);
            }
        }
        
        @keyframes gradient-flow {
            0% {
                background-position: 0% 50%;
            }
            100% {
                background-position: 300% 50%;
            }
        }
        
        @keyframes light-chase {
            0% {
                left: -20px;
            }
            100% {
                left: 100%;
            }
        }
        
        @keyframes pixel-pulse {
            0% {
                opacity: 0.5;
                box-shadow: 0 0 5px #00ffcc;
            }
            100% {
                opacity: 1;
                box-shadow: 0 0 20px #00ffcc, 0 0 30px #00ffcc;
            }
        }
        
        @keyframes gradient-shift {
            0%, 100% {
                background-position: 0% 50%;
            }
            50% {
                background-position: 100% 50%;
            }
        }
        
        @keyframes multi-glow {
            0% {
                opacity: 0.3;
                transform: scale(1);
            }
            100% {
                opacity: 0.8;
                transform: scale(1.05);
            }
        }
        
        @keyframes dot-pulse {
            0%, 100% {
                transform: scale(1);
                box-shadow: 0 0 10px #00ffcc;
            }
            50% {
                transform: scale(1.5);
                box-shadow: 0 0 20px #00ffcc, 0 0 30px #00ffcc;
            }
        }
        
        @keyframes irregular-glow {
            0%, 100% {
                opacity: 0.7;
                background-position: 0% 50%;
            }
            50% {
                opacity: 1;
                background-position: 100% 50%;
            }
        }
        
        /* 代碼展示區域 */
        .code-block {
            background: rgba(15, 15, 35, 0.8);
            border-radius: 20px;
            padding: 30px;
            margin-top: 30px;
            max-width: 900px;
            overflow-x: auto;
            border-left: 5px solid #ff0080;
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
            backdrop-filter: blur(10px);
        }
        
        .code-block h2 {
            color: #ff0080;
            margin-bottom: 20px;
            display: flex;
            align-items: center;
            gap: 10px;
            font-size: 1.8rem;
        }
        
        .code-block pre {
            color: #c5c8d3;
            font-size: 0.95rem;
            line-height: 1.5;
        }
        
        /* 交互演示區域 */
        .interactive-demo {
            background: rgba(15, 15, 35, 0.8);
            border-radius: 20px;
            padding: 30px;
            margin-top: 40px;
            max-width: 900px;
            border-left: 5px solid #00ffcc;
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
            backdrop-filter: blur(10px);
        }
        
        .interactive-demo h2 {
            color: #00ffcc;
            margin-bottom: 20px;
            display: flex;
            align-items: center;
            gap: 10px;
            font-size: 1.8rem;
        }
        
        .controls {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            margin-bottom: 30px;
        }
        
        .control-group {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }
        
        .control-group label {
            color: #a0a0d0;
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        
        .control-group input, .control-group select {
            padding: 12px;
            border-radius: 8px;
            border: 1px solid rgba(100, 150, 255, 0.3);
            background: rgba(10, 10, 25, 0.8);
            color: white;
            font-size: 1rem;
        }
        
        .demo-border-container {
            display: flex;
            justify-content: center;
            margin-top: 30px;
            min-height: 150px;
        }
        
        #custom-border {
            width: 250px;
            height: 100px;
            background: rgba(10, 10, 30, 0.8);
            border-radius: 15px;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            font-size: 1.3rem;
            font-weight: 600;
            color: #fff;
            cursor: pointer;
        }
        
        /* 底部區域 */
        .footer {
            margin-top: 40px;
            text-align: center;
            color: #7070a0;
            font-size: 0.9rem;
            padding: 20px;
            max-width: 800px;
        }
        
        /* 響應式設計 */
        @media (max-width: 768px) {
            .container {
                grid-template-columns: 1fr;
            }
            
            h1 {
                font-size: 2.5rem;
            }
            
            .border-container {
                transform: scale(0.9);
            }
            
            .controls {
                grid-template-columns: 1fr;
            }
        }
    </style>
</head>
<body>
    <div class="header">
        <h1>
            <span class="title-neon">霓虹脈衝</span>
            <span class="title-border">光效邊框</span>
        </h1>
        <p class="subtitle">今日主題:炫酷的霓虹脈衝光效邊框 - 使用CSS box-shadow、clip-path和動畫創建未來感十足的霓虹邊框效果</p>
    </div>
    
    <div class="container">
        <div class="neon-card">
            <h3 class="card-title"><i class="fas fa-border-all"></i> 基本霓虹脈衝</h3>
            <p class="card-desc">多層box-shadow創建霓虹光暈,帶有脈衝動畫效果</p>
            <div class="border-container">
                <div class="border-1">脈衝邊框</div>
            </div>
        </div>
        
        <div class="neon-card">
            <h3 class="card-title"><i class="fas fa-stream"></i> 漸變流動邊框</h3>
            <p class="card-desc">漸變背景動畫創造流動光效,顏色隨時間變化</p>
            <div class="border-container">
                <div class="border-2"><span>流動邊框</span></div>
            </div>
        </div>
        
        <div class="neon-card">
            <h3 class="card-title"><i class="fas fa-running"></i> 光點追逐效果</h3>
            <p class="card-desc">光點在邊框上追逐移動,創造動態光效</p>
            <div class="border-container">
                <div class="border-3">
                    追逐邊框
                    <div class="light-chase"></div>
                </div>
            </div>
        </div>
        
        <div class="neon-card">
            <h3 class="card-title"><i class="fas fa-th-large"></i> 像素脈衝邊框</h3>
            <p class="card-desc">clip-path創建像素風格邊框,帶有脈衝光效</p>
            <div class="border-container">
                <div class="border-4">像素邊框</div>
            </div>
        </div>
        
        <div class="neon-card">
            <h3 class="card-title"><i class="fas fa-gem"></i> 菱形霓虹邊框</h3>
            <p class="card-desc">菱形形狀邊框,漸變背景動畫創造炫酷效果</p>
            <div class="border-container">
                <div class="border-5">菱形邊框</div>
            </div>
        </div>
        
        <div class="neon-card">
            <h3 class="card-title"><i class="fas fa-layer-group"></i> 多層光暈邊框</h3>
            <p class="card-desc">多層邊框疊加,不同顏色光暈交替脈衝</p>
            <div class="border-container">
                <div class="border-6">多層邊框</div>
            </div>
        </div>
        
        <div class="neon-card">
            <h3 class="card-title"><i class="fas fa-circle"></i> 圓點連接邊框</h3>
            <p class="card-desc">邊框四角圓點獨立脈衝,創造連接點效果</p>
            <div class="border-container">
                <div class="border-7">
                    圓點邊框
                    <div class="dot-border">
                        <div class="dot"></div>
                        <div class="dot"></div>
                        <div class="dot"></div>
                        <div class="dot"></div>
                    </div>
                </div>
            </div>
        </div>
        
        <div class="neon-card">
            <h3 class="card-title"><i class="fas fa-draw-polygon"></i> 不規則光效邊框</h3>
            <p class="card-desc">不規則多邊形邊框,漸變光效流動</p>
            <div class="border-container">
                <div class="border-8">不規則邊框</div>
            </div>
        </div>
    </div>
    
    <div class="interactive-demo">
        <h2><i class="fas fa-sliders-h"></i> 自定義霓虹邊框</h2>
        <p style="color: #b0b0e0; margin-bottom: 20px;">調整以下參數,實時創建您自己的霓虹邊框:</p>
        
        <div class="controls">
            <div class="control-group">
                <label for="border-color"><i class="fas fa-palette"></i> 邊框顏色</label>
                <input type="color" id="border-color" value="#ff0080">
            </div>
            
            <div class="control-group">
                <label for="border-color2"><i class="fas fa-palette"></i> 第二顏色</label>
                <input type="color" id="border-color2" value="#00ffcc">
            </div>
            
            <div class="control-group">
                <label for="border-style"><i class="fas fa-brush"></i> 邊框樣式</label>
                <select id="border-style">
                    <option value="solid">實線光暈</option>
                    <option value="gradient">漸變流動</option>
                    <option value="pulse">脈衝效果</option>
                    <option value="chase">追逐效果</option>
                </select>
            </div>
            
            <div class="control-group">
                <label for="animation-speed"><i class="fas fa-tachometer-alt"></i> 動畫速度</label>
                <input type="range" id="animation-speed" min="1" max="10" value="5">
                <span id="speed-value">中等</span>
            </div>
        </div>
        
        <div class="demo-border-container">
            <div id="custom-border">自定義邊框</div>
        </div>
        
        <div style="text-align: center; margin-top: 20px;">
            <button id="copy-btn" class="border-1" style="padding: 15px 30px; font-size: 1rem; border: none; cursor: pointer;">
                <i class="fas fa-code" style="margin-right: 10px;"></i>
                複製CSS代碼
            </button>
        </div>
    </div>
    
    <div class="code-block">
        <h2><i class="fas fa-code"></i> 核心CSS代碼 (基本霓虹脈衝邊框)</h2>
        <pre><code>
/* 基本霓虹脈衝邊框 */
.border-1 {
    width: 200px;
    height: 100px;
    background: rgba(10, 10, 30, 0.8);
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    font-size: 1.3rem;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    
    /* 多層box-shadow創建霓虹光暈效果 */
    box-shadow: 
        0 0 5px #ff0080,        /* 第一層:輕微光暈 */
        0 0 10px #ff0080,       /* 第二層:中等光暈 */
        0 0 15px #ff0080,       /* 第三層:較強光暈 */
        0 0 20px #ff0080,       /* 第四層:強光暈 */
        inset 0 0 10px rgba(255, 0, 128, 0.3); /* 內部光暈 */
    
    /* 脈衝動畫 */
    animation: neon-pulse-1 2s infinite alternate;
}

/* 外部漸變邊框(懸停時顯示) */
.border-1::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    background: linear-gradient(45deg, #ff0080, #00ffcc, #ff0080, #00ffcc);
    border-radius: 18px;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.border-1:hover::before {
    opacity: 1;
    animation: border-rotate 4s linear infinite;
}

/* 脈衝動畫定義 */
@keyframes neon-pulse-1 {
    0% {
        box-shadow: 
            0 0 5px #ff0080,
            0 0 10px #ff0080,
            0 0 15px #ff0080,
            0 0 20px #ff0080,
            inset 0 0 10px rgba(255, 0, 128, 0.3);
    }
    100% {
        box-shadow: 
            0 0 10px #ff0080,
            0 0 20px #ff0080,
            0 0 30px #ff0080,
            0 0 40px #ff0080,
            inset 0 0 20px rgba(255, 0, 128, 0.5);
    }
}

/* 旋轉動畫定義 */
@keyframes border-rotate {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* 懸停效果 */
.border-1:hover {
    transform: scale(1.05);
}
        </code></pre>
    </div>
    
    <div class="footer">
        <p>每天一個CSS小樣式 | 炫酷的霓虹脈衝光效邊框</p>
        <p>使用純CSS實現,無需JavaScript(交互演示部分除外)</p>
        <p>提示:點擊邊框可以查看點擊效果,嘗試自定義工具創建您自己的霓虹邊框!</p>
    </div>

    <script>
        // 自定義霓虹邊框功能
        const borderColorInput = document.getElementById('border-color');
        const borderColor2Input = document.getElementById('border-color2');
        const borderStyleSelect = document.getElementById('border-style');
        const animationSpeedSlider = document.getElementById('animation-speed');
        const speedValue = document.getElementById('speed-value');
        const customBorder = document.getElementById('custom-border');
        const copyBtn = document.getElementById('copy-btn');
        
        // 速度映射
        const speedMap = {
            1: '非常慢',
            2: '很慢',
            3: '慢',
            4: '稍慢',
            5: '中等',
            6: '稍快',
            7: '快',
            8: '很快',
            9: '非常快',
            10: '極快'
        };
        
        // 動畫速度映射(秒)
        const animationSpeedMap = {
            1: 4,
            2: 3.5,
            3: 3,
            4: 2.5,
            5: 2,
            6: 1.5,
            7: 1.2,
            8: 1,
            9: 0.8,
            10: 0.6
        };
        
        // 更新自定義邊框
        function updateCustomBorder() {
            const color1 = borderColorInput.value;
            const color2 = borderColor2Input.value;
            const style = borderStyleSelect.value;
            const speed = parseInt(animationSpeedSlider.value);
            
            // 清除現有樣式
            customBorder.innerHTML = '自定義邊框';