|  | 
|  | 1 | +<!DOCTYPE html> | 
|  | 2 | +<html lang="en"> | 
|  | 3 | + <head> | 
|  | 4 | + <meta charset="UTF-8" /> | 
|  | 5 | + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | 
|  | 6 | + <title>Colorful Glowing Button</title> | 
|  | 7 | + <style> | 
|  | 8 | + body { | 
|  | 9 | + font-family: Arial, sans-serif; | 
|  | 10 | + background-color: #000000; | 
|  | 11 | + color: #ffffff; | 
|  | 12 | + display: flex; | 
|  | 13 | + justify-content: center; | 
|  | 14 | + align-items: center; | 
|  | 15 | + height: 100vh; | 
|  | 16 | + margin: 0; | 
|  | 17 | + } | 
|  | 18 | + | 
|  | 19 | + .glowing-button { | 
|  | 20 | + border: none; | 
|  | 21 | + background-color: #1f1f1f; | 
|  | 22 | + color: white; | 
|  | 23 | + padding: 15px 30px; | 
|  | 24 | + font-size: 16px; | 
|  | 25 | + font-weight: bold; | 
|  | 26 | + border-radius: 50px; | 
|  | 27 | + cursor: pointer; | 
|  | 28 | + position: relative; | 
|  | 29 | + text-transform: uppercase; | 
|  | 30 | + transition: all 0.3s ease; | 
|  | 31 | + } | 
|  | 32 | + | 
|  | 33 | + .glowing-button::after { | 
|  | 34 | + content: ""; | 
|  | 35 | + position: absolute; | 
|  | 36 | + top: 0; | 
|  | 37 | + left: 0; | 
|  | 38 | + width: 100%; | 
|  | 39 | + height: 100%; | 
|  | 40 | + border-radius: 50px; | 
|  | 41 | + background: conic-gradient( | 
|  | 42 | + from 0deg, | 
|  | 43 | + #ff0000, | 
|  | 44 | + #ff7300, | 
|  | 45 | + #ffeb00, | 
|  | 46 | + #47ff00, | 
|  | 47 | + #00ffee, | 
|  | 48 | + #2b65ff, | 
|  | 49 | + #8000ff, | 
|  | 50 | + #ff0000 | 
|  | 51 | + ); | 
|  | 52 | + opacity: 0; | 
|  | 53 | + transition: all 0.3s ease; | 
|  | 54 | + /* z-index 创建了一个新的 stacking context,这样它就能放在 button 的下边。 | 
|  | 55 | + 因为 ::before 和 ::after 是在原元素本身内部创建新的元素。 | 
|  | 56 | + 如果想把伪元素的背景覆盖到父元素上边,需要给 button 设置 z-index: 1 */ | 
|  | 57 | + z-index: -1; | 
|  | 58 | + filter: blur(12px); | 
|  | 59 | + } | 
|  | 60 | + | 
|  | 61 | + .glowing-button:hover::after { | 
|  | 62 | + opacity: 1; | 
|  | 63 | + scale: 1.2; | 
|  | 64 | + } | 
|  | 65 | + | 
|  | 66 | + /* .glowing-button:hover { | 
|  | 67 | + box-shadow: 0 0 30px #ff0000, 0 0 40px #47ff00, 0 0 50px #2b65ff; | 
|  | 68 | + } */ | 
|  | 69 | + </style> | 
|  | 70 | + </head> | 
|  | 71 | + <body> | 
|  | 72 | + <div style="text-align: center"> | 
|  | 73 | + <button class="glowing-button">Button</button> | 
|  | 74 | + </div> | 
|  | 75 | + </body> | 
|  | 76 | +</html> | 
0 commit comments