【爱心表白-----使用HTML+CSS+JS实现(效果+源代码

  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是一个简单的HTML+CSS+JavaScript制作的卡通人物爱心表白代码,带有爱心形状浮动特效: ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>卡通人物爱心表白</title> <style> body { background-color: #FFC0CB; font-family: Arial, sans-serif; } .container { margin: 0 auto; text-align: center; padding-top: 50px; } #heart { width: 100px; height: 90px; position: relative; margin: 0 auto; animation: heart-float 1s ease-in-out infinite; } #heart:before, #heart:after { content: ""; position: absolute; left: 50px; top: 0; width: 50px; height: 80px; background: #FFC0CB; border-radius: 50px 50px 0 0; transform: rotate(-45deg); transform-origin: 0 100%; } #heart:after { left: 0; transform: rotate(45deg); transform-origin: 100% 100%; } #text { margin-top: 50px; font-size: 24px; color: white; text-shadow: 1px 1px #FF69B4; } @keyframes heart-float { 0% { transform: translateY(0); } 50% { transform: translateY(-10px); } 100% { transform: translateY(0); } } </style> </head> <body> <div class="container"> <div id="heart"></div> <div id="text">亲爱的,我爱你!</div> </div> <script> document.getElementById("text").addEventListener("mouseover", function() { this.style.color = "#FF69B4"; this.style.textShadow = "2px 2px #F08080"; }); document.getElementById("text").addEventListener("mouseout", function() { this.style.color = "white"; this.style.textShadow = "1px 1px #FF69B4"; }); </script> </body> </html> ``` 这个代码实现了一个卡通人物爱心表白效果,其中爱心形状使用CSS中的伪元素:before和:after来实现,浮动特效使用CSS3中的animation属性,而文字颜色的变化使用JavaScript实现

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值