HTML动态爱心点赞原代码
<!DOCTYPE html> <html> <head> <Meta charset="UTF-8"> <title>爱心点赞特效</title> <style> body{ margin: 0; padding: 0; background-color: #f9f9f9; text-align: center; font-family: 'Microsoft YaHei'; } h1{ color: #f92362; font-size: 54px; margin-top: 100px; } .like-Box{ margin-top: 50px; display: inline-block; position: relative; cursor: pointer; user-select: none; transform: scale(1); transition: all .2s ease-in-out; } .like-icon{ height: 80px; width: 80px; background-image: url('heart.png'); background-repeat: no-repeat; background-position: 0 0; display: inline-block; position: relative; vertical-align: middle; transform-origin: center center; transition: all .2s ease-out; } .like-icon.open{ transform: scale(1.2); } .like-over{ width: 100%; height: 100%; position: absolute; left: 0; top: 0; opacity: 0; background: linear-gradient(#f92362,#f3d743); transform: scale(0); transform-origin: center center; transition: all .5s cubic-bezier(0.55,0.06,0.68,0.19); } .like-over.open{ opacity: 1; transform: scale(2.5); } </head> <body> <h1>HTML动态爱心点赞特效</h1> <div class="like-Box"> <div class="like-icon"></div> <div class="like-over"></div> </div> <script> const likeBox = document.querySelector('.like-Box') likeBox.addEventListener('click',function(){ this.querySelector('.like-icon').classList.toggle('open') this.querySelector('.like-over').classList.toggle('open') }) </script> </body> </html>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。