HTML5紅包源代碼
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML5紅包源代碼</title> </head> <body> <div id="red-envelope"> <div id="envelope-icon"></div> <div id="envelope-text">恭喜發(fā)財(cái),大吉大利!</div> </div> <script type="text/javascript"> var redEnvelope = document.getElementById('red-envelope'); redEnvelope.onclick = function() { redEnvelope.classList.add('opened'); }; </script> <style> #red-envelope { width: 200px; height: 200px; background-color: #f00; border-radius: 50%; position: relative; cursor: pointer; transition: all 0.5s ease-in-out; } #envelope-icon { width: 100px; height: 100px; background-color: #fff; border-radius: 50px; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } #envelope-text { font-size: 18px; font-weight: bold; color: #fff; position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); text-align: center; } #red-envelope.opened { background-color: #fd0; } </style> </body> </html>