位置: IT常识 - 正文

HTML创意动画代码(html制作动画代码)

编辑:rootadmin
HTML创意动画代码 目录1、动态气泡背景2、创意文字3、旋转立方体1、动态气泡背景

推荐整理分享HTML创意动画代码(html制作动画代码),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:html制作动画代码,html动画设计,html 动画,html制作动画代码,html5动画代码,html 动画,html动画设计,html动画制作,内容如对您有帮助,希望把文章链接给更多的朋友!

<!DOCTYPE html><html><head><title>Bubble Background</title><style>body {margin: 0;padding: 0;height: 100vh;background: #222;display: flex;flex-direction: column;align-items: center;justify-content: center;overflow: hidden;}canvas {position: absolute;top: 0;left: 0;width: 100%;height: 100%;}h1 {color: white;font-size: 4rem;z-index: 1;}</style></head><body><canvas id="canvas"></canvas><h1>Hello Boy!</h1><script>const canvas = document.getElementById("canvas");const ctx = canvas.getContext("2d");canvas.width = window.innerWidth;canvas.height = window.innerHeight;class Bubble {constructor(x, y, radius, color) {this.x = x;this.y = y;this.radius = radius;this.color = color;this.dx = Math.random() - 0.5;this.dy = Math.random() - 0.5;this.speed = Math.random() * 5 + 1;}draw() {ctx.beginPath();ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2);ctx.fillStyle = this.color;ctx.fill();}update() {if (this.x + this.radius > canvas.width || this.x - this.radius < 0) {this.dx = -this.dx;}if (this.y + this.radius > canvas.height || this.y - this.radius < 0) {this.dy = -this.dy;}this.x += this.dx * this.speed;this.y += this.dy * this.speed;}}const bubbles = [];function init() {for (let i = 0; i < 50; i++) {const radius = Math.random() * 50 + 10;const x = Math.random() * (canvas.width - radius * 2) + radius;const y = Math.random() * (canvas.height - radius * 2) + radius;const color = `hsla(${Math.random() * 360}, 100%, 50%, 0.8)`;bubbles.push(new Bubble(x, y, radius, color));}}function animate() {requestAnimationFrame(animate);ctx.clearRect(0, 0, canvas.width, canvas.height);bubbles.forEach((bubble) => {bubble.draw();bubble.update();});}init();animate();</script></body></html>HTML创意动画代码(html制作动画代码)

这个代码使用了 Canvas 技术,创建了一个随机生成的气泡背景并且让气泡动态漂浮,形成了一个很有趣的效果。你可以在这个基础上尝试进行一些自己的创意,比如修改气泡的数量、大小、颜色,以及运动的方式等等。

2、创意文字

<!DOCTYPE html><html><head><title>Rainbow Text</title><style>body {background: black;color: white;font-family: 'Open Sans', sans-serif;text-align: center;height: 100%;display: flex;flex-direction: column;justify-content: center;}h1 {font-size: 8em;margin: 100px auto;animation: rainbow 5s ease-in-out infinite;}@keyframes rainbow {0% {color: #ff0000;text-shadow: 0 0 10px #ff0000, 0 0 20px #ff0000, 0 0 30px #ff0000;}25% {color: #ff8000;text-shadow: 0 0 10px #ff8000, 0 0 20px #ff8000, 0 0 30px #ff8000;}50% {color: #ffff00;text-shadow: 0 0 10px #ffff00, 0 0 20px #ffff00, 0 0 30px #ffff00;}75% {color: #00ff00;text-shadow: 0 0 10px #00ff00, 0 0 20px #00ff00, 0 0 30px #00ff00;}100% {color: #0000ff;text-shadow: 0 0 10px #0000ff, 0 0 20px #0000ff, 0 0 30px #0000ff;}}</style></head><body><h1>Hello Girl</h1></body></html>

这个代码使用了 CSS 的动画和阴影特效,让页面中的文字在红、橙、黄、绿、蓝五种颜色之间不断变化,形成了一个很有趣的效果。你可以在这个基础上尝试进行一些自己的创意,比如修改文字的大小、样式、颜色,以及变化的频率和方式等等。

3、旋转立方体

<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>旋转立方体</title> <style> #cube { width: 200px; height: 200px; position: relative; transform-style: preserve-3d; animation: rotate 6s infinite linear;margin: 100px auto; } #cube div { position: absolute; width: 200px; height: 200px; background-color: rgba(0, 255, 255, 0.5); border: 2px solid #333; } #cube .front { transform: translateZ(100px); } #cube .back { transform: rotateY(180deg) translateZ(100px); } #cube .right { transform: rotateY(90deg) translateZ(100px); } #cube .left { transform: rotateY(-90deg) translateZ(100px); } #cube .top { transform: rotateX(90deg) translateZ(100px); } #cube .bottom { transform: rotateX(-90deg) translateZ(100px); } @keyframes rotate { 0% { transform: rotateX(0) rotateY(0) rotateZ(0); } 100% { transform: rotateX(360deg) rotateY(360deg) rotateZ(360deg); } } </style> </head> <body> <div id="cube"> <div class="front"></div> <div class="back"></div> <div class="right"></div> <div class="left"></div> <div class="top"></div> <div class="bottom"></div> </div> <script> const cube = document.querySelector('#cube'); let isPaused = false; cube.addEventListener('mouseover', () => { isPaused = true; cube.style.animationPlayState = 'paused'; }); cube.addEventListener('mouseout', () => { isPaused = false; cube.style.animationPlayState = 'running'; }); setInterval(() => { if (!isPaused) { cube.style.animationPlayState = 'running'; } }, 1000); </script> </body></html>

该示例中,我们使用了 transform-style: preserve-3d 属性来创建 3D 空间通过对立方体不同面的旋转实现了立方体的旋转效果。我们还使用了 CSS 动来实现无限循环的旋转效果,并使用 JavaScript 实现了当鼠标悬停在立方体上时暂停动画的交互效果。

本文链接地址:https://www.jiuchutong.com/zhishi/295917.html 转载请保留说明!

上一篇:Opencv项目实战:18 人体姿态检测(opencv开发项目)

下一篇:AI生成图像竟如此真实了?Stable Diffusion Model本地部署教程(ai生成图形)

  • 公司办资质的发票入什么科目
  • 企业购买产品
  • 异地预缴税款不交可以吗
  • 受雇于两家公司个税怎么汇算清缴
  • 企业所得税零申报表怎么填写
  • 补提盈余公积的分录
  • 售后维修的配件开维修费
  • 财政拨付的研发费用
  • 手工记账需要什么资质
  • 预付账款转入其他非流动资产
  • 预付款对应的会计科目
  • 公司代扣代缴个人所得税能查到吗
  • 怎么辨认专用发票真伪
  • 所有的罚款都不能税前扣除吗
  • 水费税收分类编码
  • 符合免税条件的一般纳税人开具发票税率
  • 契税和印花税入哪个科目
  • 万元的票可以开到多大金额
  • 19年入职19年离职
  • 收入与应收款
  • 发票作废时间有多长
  • 物业税额
  • 代收代缴水电费能开发票吗
  • 印花税本月计提本月缴纳
  • 关闭guest账户
  • 如何编辑受保护的word文档
  • 报销冲借款是什么意思
  • 电脑软件如何开机自启动
  • 私账转到公账怎么办
  • "php"
  • shwicon.exe - shwicon是什么进程 有什么用
  • 个人所得税如何计算
  • php pdo oracle
  • vue-router
  • 超经营范围开具发票
  • 以前年度少记税金及附加
  • Win11 Build 23435 预览版今日发布: 文件管理器引入图库功能
  • 最优化理论pdf
  • 免征个人所得税33种情形
  • java桥接模式的应用场景
  • 长期股权投资权益法转成本法
  • 个人取得的劳务报酬所得,如何缴纳个税
  • 专家咨询费比例不能超过多少
  • java静态方法和动态方法的区别
  • vue this.$ref
  • 给对方开发票需要
  • 报销人和收款人不一致钱打到哪个账户
  • 新成立的小公司财务怎么管理
  • MySQL ERROR 2013 (HY000)错误解决方法
  • 个体户是什么概念
  • 电梯改造税率
  • 办理契税所需要的证件
  • 支持疫情的句子 关于抗击疫情的句子
  • 营改增企业是什么意思
  • 服务行业收入会增加吗
  • 以前年度费用怎么记账
  • 老板垫付工资账务处理
  • 工资表明细表
  • 个体工商户的纳税标准
  • mysql安全性控制语句
  • mysql 5.7.11 zip安装配置方法图文教程
  • 怎么设置win7密码
  • w10预览版新功能
  • win2008 server r2 intel无法安装网卡驱动不存在英特尔PRO适配器的解决方法
  • win7系统怎么用
  • centos怎么设置
  • win8的安全中心
  • 怎么关闭无服务状态
  • Win7系统打开文件夹没有自动排列选项
  • android xui
  • 学习笔记一
  • ext.grid.panel
  • unity 加载界面
  • 安卓解析工具
  • 如何修改新建的内容
  • 安卓中的菜单
  • 重庆市医疗保障局
  • 工信厅有什么实权
  • 房地产预缴土增值税
  • 深圳国税局网站如何查询企业往年财务报表
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设