Để tạo văn bản phát sáng bằng CSS, mã như sau -
Ví dụ
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> body { background-color: rgb(0, 0, 0); font-family: cursive; } .glowing { font-size: 80px; color: #fff; text-align: center; -webkit-animation: glowing 1s ease-in-out infinite alternate; -moz-animation: glowing 1s ease-in-out infinite alternate; animation: glowing 1s ease-in-out infinite alternate; } @-webkit-keyframes glowing{ from { text-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #4f00b6, 0 0 40px #17057c, 0 0 50px #29c2ff, 0 0 60px #96fbff, 0 0 70px #1f0352; } to { text-shadow: 0 0 20px #fff, 0 0 30px #2b4ebe, 0 0 40px #4276e6, 0 0 50px #4644cf, 0 0 60px #3533d1, 0 0 70px #493cbb, 0 0 80px #8beeff; } } </style> </head> <body> <h1 class="glowing">GLOWING TEXT EXAMPLE</h1> </body> </html>
Đầu ra
Đoạn mã trên sẽ tạo ra kết quả sau -