位置: 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生成图形)

  • 逾期未申报是什么意思
  • 企业个人所得税税率表2023
  • 国际运输需要办什么证
  • 应交城建税分录
  • 住宿费取得增值税专用发票,抵扣进项税额如何计算
  • 民办非营利组织幼儿园清算时固定资产如何处理
  • 怎么处理善意取得的大头小尾发票?
  • 报销购物卡发票公司如何交税?
  • 财务费用利息收入的账务处理
  • 固定资产进项抵扣新政策2021
  • 代扣工资申请怎么写
  • 开餐饮发票的经营范围是怎样的?
  • 社保发票是普票还是专票
  • 出口转内销进项转出
  • 电子钥匙的发票怎么开
  • 2021年个人开发票税率
  • 零余额账户期末怎么结转?
  • 填写报关单需要什么资料
  • 税后利润分配需要计提吗
  • 华为手机屏幕碎了照片
  • 如何理解结转利润的意思
  • 电脑开机硬盘自检怎么回事
  • 公司筹建期间发生的业务招待费,如何税前扣除
  • 加工费的会计处理
  • 生产成本在资产负债表中怎么填
  • 补缴增值税怎么做账
  • php如何提高程序运行效率
  • 福利企业增值税优惠政策
  • 一条指令可以完成一项复杂任务吗
  • PHP基于SimpleXML生成和解析xml的方法示例
  • php bool
  • 应付保理怎么做账
  • 营改增抵减的销项税发票要抵扣吗
  • 兼职工作是单位工作吗
  • 小规模纳税人怎么核定税种
  • 租金计入主营业务成本吗
  • 交给工会的40%的工会经费里还要再返60%吗
  • 所得税汇算会计处理
  • 政府向企业发放用工补贴政策
  • 购房补贴退契税3个月没到账
  • 善意取得虚开发票罪认定
  • 小企业资本公积的来源有
  • 冲减以前年度管理费用需要更正报表吗
  • 借贷记账法的基本规则和账户结构
  • 一般纳税人劳务税率是多少?
  • 递延收益什么科目
  • 自产产品对外捐赠确认收入吗
  • 跨年度发票的报表怎么填
  • 跨年的施工项目成本
  • 新政府会计下专业学什么
  • 企业计提什么意思
  • 社保逾期滞纳金和利息
  • 企业购买国债逆回购要交企业所得税吗
  • 外包加工如何做账
  • 企业注销递延所得税资产怎么处理
  • 公司社保委托代发银行是工资卡银行吗
  • 开具其他发票收入填报异常
  • 库存现金的主要内容有哪些
  • 年末进项大于销项怎么结转
  • 跨境汇款汇错
  • 勒索病毒2021
  • 电脑出现bootbcd
  • mac自动操作怎么停止
  • redhat linux6.5安装教程
  • Win10预览版镜像
  • 铁嘴银牙剧情简介
  • css中文名称
  • Linux进程间通信——使用流套接字
  • idea 分析源码
  • 百度定位服务平台
  • 怎么利用python处理批量表格
  • 基于JQuery的$.ajax方法进行异步请求导致页面闪烁的解决办法
  • python约瑟夫问题最高效算法
  • jquery设置背景颜色
  • 上海各区税务大厅
  • 英国税务局缴纳税款方式
  • 辽宁交管12123能用微信支付吗
  • 乡镇四所是指哪些所
  • 开通税务在哪里弄
  • 禅城有什么小孩好玩的地方
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设