โค้ดต่อไปนี้เป็นการสร้าง Fading Buttons ด้วย CSS
ตัวอย่าง
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> button { background-color: rgb(255, 175, 222); border: none; color: black; padding: 25px; text-align: center; font-size: 20px; margin: 4px 2px; transition: 0.3s; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; font-weight: bolder; } button:hover { background-color: #4d0036; color: white; } </style> </head> <body> <h1>Fading Button Example</h1> <button>Hover Here</button> <h1>Hover on the above button to see background fade on button</h1> </body> </html>ผลลัพธ์
โค้ดข้างต้นจะสร้างผลลัพธ์ดังนี้

เมื่อ Hover Button พื้นหลังสีเข้มจะ Fade In
