1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>流光</title> </head> <body> <a href="#" class="box"> <span></span> <span></span> <span></span> <span></span> hello world </a> <a href="#" class="box"> <span></span> <span></span> <span></span> <span></span> hello world </a> <a href="#" class="box"> <span></span> <span></span> <span></span> <span></span> hello world </a> <a href="#" class="box"> <span></span> <span></span> <span></span> <span></span> <p>hello world</p> <p>hello world</p> </a> <a href="#" class="box light"> <p>hello world</p> </a> <style> body { background: #000; display: flex; flex-direction: column; justify-content: center; align-items: center; } .box { position: relative; display: block; padding: 20px 30px; letter-spacing: 1px; text-decoration: none; text-transform: uppercase; width: 200px; text-align: center; margin: 100px 0 0; transition: 0.5s; color: #03f2ff; overflow: hidden; } .box:hover { background: #03f2ff; color: #000; box-shadow: 0 0 5px #03f2ff, 0 0 25px #03f2ff, 0 0 50px #03f2ff, 0 0 200px #03f2ff; -webkit-box-reflect: below 1px linear-gradient(transparent, #000); } .box:nth-child(1):hover { width: 300px; } .box:nth-child(1) { filter: hue-rotate(270deg); } .box:nth-child(2) { filter: hue-rotate(110deg); } .box:nth-child(4) { background: rgba(15, 53, 76, 0.8); color: white; font-size: 12px; } /* 流光效果 */ .box span { position: absolute; display: block; } /* 从左到右 */ .box span:nth-child(1) { top: 0; left: 0; width: 100%; height: 1px; background: linear-gradient(90deg, transparent, #03f2ff); animation: animate1 1s linear infinite; } @keyframes animate1 { 0% { left: -100%; } 50%, 100% { left: 100%; } } /* 从上到下 */ .box span:nth-child(2) { top: -100%; right: 0; width: 1px; height: 100%; background: linear-gradient(180deg, transparent, #03f2ff); animation: animate2 1s linear infinite; animation-delay: 0.25s; } @keyframes animate2 { 0% { top: -100%; } 50%, 100% { top: 100%; } } /* 从右到左 */ .box span:nth-child(3) { right: -100%; bottom: 0; width: 100%; height: 1px; background: linear-gradient(270deg, transparent, #03f2ff); animation: animate3 1s linear infinite; animation-delay: 0.5s; } @keyframes animate3 { 0% { right: -100%; } 50%, 100% { right: 100%; } } /* 从下到上 */ .box span:nth-child(4) { bottom: -100%; left: 0; width: 1px; height: 100%; background: linear-gradient(360deg, transparent, #03f2ff); animation: animate4 1s linear infinite; animation-delay: 0.75s; } @keyframes animate4 { 0% { bottom: -100%; } 50%, 100% { bottom: 100%; } } /* 闪烁 */ .light { width: 100%; height: 100%; background: linear-gradient(to right, transparent, rgba(48, 251, 253, 0.48), transparent) center bottom no-repeat; animation: glint 2s ease-in-out infinite; position: relative; } .light::after { content: ''; position: absolute; width: 100%; height: 2px; bottom: 0; left: 0; background: linear-gradient(90deg, transparent, transparent, rgba(48, 251, 253), transparent, transparent); box-shadow: 0 -1px 10px #03f2ff; } /* 呼吸灯 */ @keyframes glint { from { opacity: 0.1; } /* 动画开始时的不透明度 */ 50% { opacity: 1; } /* 动画50% 时的不透明度 */ to { opacity: 0.1; } /* 动画结束时的不透明度 */ } </style> </body> </html> |