用HTML5+CSS+JavaScript庆祝国庆

news2024/10/6 12:46:45

用HTML5+CSS+JavaScript庆祝国庆

中华人民共和国的国庆日是每年的10月1日。

1949年10月1日,中华人民共和国中央人民政府成立,在首都北京天安门广场举行了开国大典,中央人民政府主席毛泽东庄严宣告中华人民共和国成立,并亲手升起了第一面五星红旗。这一历史性的时刻标志着新中国的诞生。1949年12月2日,中央人民政府委员会第四次会议接受全国政协的建议,通过了《关于中华人民共和国国庆日的决议》,决定每年10月1日为中华人民共和国国庆日。

国庆日这一天,全国各地都会举行各种庆祝活动,如悬挂国旗、唱国歌、文艺演出、烟花表演等方式来庆祝这一重要节日。

现在,让我们用HTML5+CSS+JavaScript庆祝中华人民共和国的国庆日。

先看用css3画五星红旗效果:

用css3画五星红旗源码如下:

<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS画五星红旗</title>
    <style>
        .flag{
            width: 300px;
            height: 200px;
            background-color: red;
            position: relative;
        }

        body {
            display: flex;
            height: 100vh; /* 页面高度 */
            justify-content: center; /* 水平居中 */
            align-items: center; /* 垂直居中 */
            margin: 0; /* 去掉默认边距 */
        }
        .star{
            margin: 0 0;
            position: absolute;
            display: block;
            /* color: red; */
            width: 0;
            height: 0;
            border-right: 100px solid transparent;
            border-bottom: 70px solid yellow;/* */
            border-left: 100px solid transparent;
            transform: rotate(35deg);
            left: 20px;
        }
        .star:before {
            border-bottom: 80px solid yellow;
            border-left: 30px solid transparent;
            border-right: 30px solid transparent;
            position: absolute;
            height: 0;
            width: 0;
            top: -45px;
            left: -65px;
            display: block;
            content: '';
            transform: rotate(-35deg);
        }
        .star:after{
            content: '';
            margin: 0;
            position: absolute;
            display: block;
            /* color: red; */
            width: 0;
            height: 0;
            border-right: 100px solid transparent;
            border-bottom: 70px solid yellow;/* */
            border-left: 100px solid transparent;
            transform: rotate(-70deg);
            left: -107px;
            top: 5px;
        }
        .big{
            /* position: absolute; */
            transform: scale(.3) rotate(35deg);
            top: 10px;
            left: -50px;
            z-index: 3;
        }
        .little1{
            position: absolute;
            transform: scale(.1) rotate(-60deg);
            top: -15px;
            left: 5px;
        }
        .little2{
            position: absolute;
            transform: scale(.1) rotate(-45deg);
            top: 5px;
            left: 30px;
        }
        .little3{
            position: absolute;
            transform: scale(.1) rotate(35deg);
            top: 33px;
            left: 30px;
        }
        .little4{
            position: absolute;
            transform: scale(.1) rotate(60deg);
            top: 50px;
            left: 5px;
        }

 
    </style>

</head> 
<body>
    <div class="flag">
        <div class="star big"></div>
        <div class="star little1"></div>
        <div class="star little2"></div>
        <div class="star little3"></div>
        <div class="star little4"></div>
    </div>
</body>
</html>

下面添加烟花效果烘托国庆气氛

先看国庆烟花效果:

国庆烟花源码如下:

<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>国庆烟花气氛</title>
    <style>
        body {
            display: flex;
            height: 100vh; /* 页面高度 */
            justify-content: center; /* 水平居中 */
            align-items: center; /* 垂直居中 */
            margin: 0; /* 去掉默认边距 */
            position: relative;
            overflow: hidden;
            background-color: #000; /* 背景设为黑色,模拟夜空 */
        }
        .flag {
            width: 300px;
            height: 200px;
            background-color: red;
            position: relative;
            z-index: 1;
        }
        .star {
            margin: 0 0;
            position: absolute;
            display: block;
            width: 0;
            height: 0;
            border-right: 100px solid transparent;
            border-bottom: 70px solid yellow;
            border-left: 100px solid transparent;
            transform: rotate(35deg);
            left: 20px;
        }
        .star:before {
            border-bottom: 80px solid yellow;
            border-left: 30px solid transparent;
            border-right: 30px solid transparent;
            position: absolute;
            height: 0;
            width: 0;
            top: -45px;
            left: -65px;
            display: block;
            content: '';
            transform: rotate(-35deg);
        }
        .star:after {
            content: '';
            margin: 0;
            position: absolute;
            display: block;
            width: 0;
            height: 0;
            border-right: 100px solid transparent;
            border-bottom: 70px solid yellow;
            border-left: 100px solid transparent;
            transform: rotate(-70deg);
            left: -107px;
            top: 5px;
        }
        .big {
            transform: scale(.3) rotate(35deg);
            top: 10px;
            left: -50px;
            z-index: 3;
        }
        .little1 {
            position: absolute;
            transform: scale(.1) rotate(-60deg);
            top: -15px;
            left: 5px;
        }
        .little2 {
            position: absolute;
            transform: scale(.1) rotate(-45deg);
            top: 5px;
            left: 30px;
        }
        .little3 {
            position: absolute;
            transform: scale(.1) rotate(35deg);
            top: 33px;
            left: 30px;
        }
        .little4 {
            position: absolute;
            transform: scale(.1) rotate(60deg);
            top: 50px;
            left: 5px;
        }
        canvas {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none; /* 使canvas不会阻止点击事件 */
        }
    </style>
</head>
<body>
    <canvas id="fireworks"></canvas>
    <div class="flag">
        <div class="star big"></div>
        <div class="star little1"></div>
        <div class="star little2"></div>
        <div class="star little3"></div>
        <div class="star little4"></div>
    </div>
    <script>
        const canvas = document.getElementById('fireworks');
        const ctx = canvas.getContext('2d');
        canvas.width = window.innerWidth;
        canvas.height = window.innerHeight;

        function randomColor() {
            return `hsl(${Math.random() * 360}, 100%, 50%)`;
        }

        function Firework(x, y) {
            this.x = x;
            this.y = y;
            this.size = Math.random() * 10 + 5;
            this.speed = Math.random() * 6 + 2;
            this.angle = Math.random() * Math.PI * 2;
            this.color = randomColor();
            this.exploded = false;
            this.particles = [];

            this.update = function () {
                if (!this.exploded) {
                    this.y -= this.speed;
                    // 限制烟花的最大高度
                    if (this.y < canvas.height * 0.2) { // 高度限制
                        this.exploded = true;
                        this.createParticles();
                    }
                    if (this.size > 0) {
                        this.size -= 0.1;
                    } else {
                        this.exploded = true;
                        this.createParticles();
                    }
                } else {
                    this.particles.forEach(p => p.update());
                }
            };

            this.createParticles = function () {
                const particleCount = Math.random() * 100 + 50;
                for (let i = 0; i < particleCount; i++) {
                    this.particles.push(new Particle(this.x, this.y, this.color));
                }
            };

            this.draw = function () {
                if (!this.exploded) {
                    if (this.size > 0) { // 仅在大小为正时绘制。
                        ctx.fillStyle = this.color;
                        ctx.beginPath();
                        ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
                        ctx.fill();
                    }
                } else {
                    this.particles.forEach(p => p.draw());
                }
            };
        }

        function Particle(x, y, color) {
            this.x = x;
            this.y = y;
            // 将颜色分解为RGB,以便后续使用
            this.color = color.match(/\d+/g).map(Number);
            this.size = Math.random() * 3 + 2;
            this.speed = Math.random() * 3 + 1;
            this.angle = Math.random() * Math.PI * 2;
            this.alpha = 1;

            this.update = function () {
                this.x += Math.cos(this.angle) * this.speed;
                this.y += Math.sin(this.angle) * this.speed;
                this.alpha -= 0.02;
            };

            this.draw = function () {
                ctx.fillStyle = `rgba(${this.color.join(",")}, ${this.alpha})`;
                if (this.alpha > 0) { // 仅当透明度为正时绘制。
                    ctx.beginPath();
                    ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
                    ctx.fill();
                }
            };
        }

        const fireworks = [];
        function createFirework() {
            const firework = new Firework(Math.random() * canvas.width, canvas.height);
            fireworks.push(firework);
        }

        function animate() {
            ctx.clearRect(0, 0, canvas.width, canvas.height);
            fireworks.forEach((firework, index) => {
                firework.update();
                firework.draw();
                if (firework.exploded && firework.particles.length === 0) {
                    fireworks.splice(index, 1);
                }
            });
            requestAnimationFrame(animate);
        }

        for (let i = 0; i < 5; i++) {
            createFirework();
        }
        animate();

        setInterval(createFirework, 1000);
    </script>
</body>
</html>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2191912.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

茴香豆 + Qwen-7B-Chat-Int8

今天 打开config.ini 发现 茴香豆 支持 qwen/qwen-7b-chat-int8 1.0 拉取qwen/qwen-7b-chat-int8 cd /root/modelsgit clone https://gitee.com/hf-models/Qwen-7B-Chat-Int8.git 1.1 更改配置文件 茴香豆的所有功能开启和模型切换都可以通过 config.ini 文件进行修改 /roo…

【JAVA开源】基于Vue和SpringBoot的洗衣店订单管理系统

本文项目编号 T 068 &#xff0c;文末自助获取源码 \color{red}{T068&#xff0c;文末自助获取源码} T068&#xff0c;文末自助获取源码 目录 一、系统介绍二、演示录屏三、启动教程四、功能截图五、文案资料5.1 选题背景5.2 国内外研究现状5.3 可行性分析 六、核心代码6.1 顾…

Leetcode—200. 岛屿数量【中等】

2024每日刷题&#xff08;176&#xff09; Leetcode—200. 岛屿数量 C实现代码 class Solution { public:int numIslands(vector<vector<char>>& grid) {int m grid.size();int n grid[0].size();int ans 0;function<void(int, int)> dfs [&](…

企业架构TOGAF的理论指南:数字化转型中的企业架构实践

在当今全球市场的快速变革中&#xff0c;企业的数字化转型已经成为不可避免的趋势。无论是为了提高效率、增强竞争力&#xff0c;还是为了应对技术变革的挑战&#xff0c;企业都需要一个强有力的架构框架来指导其转型。TOGAF&#xff08;The Open Group Architecture Framework…

pytorch版本和cuda版本不匹配问题

文章目录 &#x1f315;问题&#xff1a;Python11.8安装pytorch11.3失败&#x1f315;CUDA版本和pytorch版本的关系&#x1f315;安装Pytorch2.0.0&#x1f319;pip方法&#x1f319;cuda方法 &#x1f315;问题&#xff1a;Python11.8安装pytorch11.3失败 &#x1f315;CUDA版…

【CSS Tricks】试试新思路去处理文本超出情况

目录 引言一、常规套路1. 单行文本省略2. 多行文本省略 二、新思路美化一下1. 单行/多行文本隐藏2. 看下效果 三、总结 引言 本篇为css的一个小技巧 文本溢出问题是一个较为常见的场景。UI设计稿为了整体的美观度会将文本内容限制到一定范围内&#xff0c;然而UI设计阶段并不能…

智慧学生宿舍管理平台|学生宿舍管理平台系统|基于Springboot+VUE的智慧学生宿舍管理平台系统设计与实现(源码+数据库+文档)

智慧学生宿舍管理平台 目录 基于SpringbootVUE的智慧学生宿舍管理平台系统设计与实现 一、前言 二、系统功能设计 三、系统实现 四、数据库设计 五、核心代码 六、论文参考 七、最新计算机毕设选题推荐 八、源码获取&#xff1a; 博主介绍&#xff1a;✌️大厂码农|毕…

余承东直播论道智能驾驶:激光雷达不可或缺,华为ADS 3.0引领安全创新

华为余承东:激光雷达,智能驾驶安全性的关键 9月29日,华为消费者业务集团CEO余承东在一场引人注目的直播中,与知名主持人马东就智能驾驶技术的最新进展进行了深入交流。在这场直播中,余承东针对激光雷达在智能驾驶中的必要性问题,发表了明确且深刻的观点,引发了业界和公众…

STM32F407 HAL库定时器触发ADC采集与DMA数据传输(定时器TIM+ADC+DMA)

在STM32F407系列微控制器的开发中&#xff0c;结合定时器、ADC&#xff08;模数转换器&#xff09;与DMA&#xff08;直接存储器访问&#xff09;控制器&#xff0c;能够显著提升数据采集与传输的效率。本文将指导你如何使用STM32 HAL库&#xff0c;通过定时器触发ADC1的单通道…

认知战认知作战:欧盟向中国纯电动车加关税为背景的认知作战方式与策略

认知战认知作战&#xff1a;欧盟向中国纯电动车加关税为背景的认知作战方式与策略 关键词&#xff1a;欧盟, 中国, 纯电动车, 关税, 认知战, 舆论战, 政治动员, 外交反击, 市场份额, 保护主义, 技术升级, 中立第三方, 友军, 国际贸易, 合作与竞争,认知作战,新质生产力,人类命运…

信号用wire类型还是reg类型定义

wire类型就是一根线&#xff0c;线有两端&#xff0c;一端发生改变&#xff0c;经过线传递的信号当然也会发生改变&#xff0c;reg类型则不同&#xff0c;可以把reg类型理解为存储数据的寄存器&#xff0c;当满足一定条件时&#xff0c;数值才被激活发生改变。 那么&#xff0…

英国本科毕业论文写作如何确立论点

英国本科毕业论文关系到留学生是否能顺利毕业。因此&#xff0c;写好英国本科毕业论文也便成了留学生在毕业季的头等大事。那么应当怎么做才能更好地完成毕业论文呢&#xff1f;在本文中&#xff0c;英国翰思教育将从论点这个内容展开说说&#xff0c;如果高质量地完成毕业论文…

2024 uniapp入门教程 01:含有vue3基础 我的第一个uniapp页面

uni-app官网uni-app,uniCloud,serverless,快速体验,看视频&#xff0c;10分钟了解uni-app,为什么要选择uni-app&#xff1f;,功能框架图,一套代码&#xff0c;运行到多个平台https://uniapp.dcloud.net.cn/ 准备工作&#xff1a;HBuilder X 软件 HBuilder X 官网下载&#xf…

AI产品经理的崛起

“It will be unthinkable not to have artificial intelligence integrated into a product. Because everyone will expect it.” _Sam Altman, CEO & Co-founder (OpenAI)_正如Sam Altman所说的&#xff0c;2024年人工智能技术继续快速发展。我们看到了各种AI模型&#…

[Python] 《人生重开模拟器》游戏实现

文章目录 优化点一&#xff1a;多元化的天赋系统示例天赋&#xff1a;天赋选择代码&#xff1a; 优化点二&#xff1a;更加多样化的随机事件年龄阶段划分&#xff1a;随机事件代码&#xff1a; 优化点三&#xff1a;设定人生目标人生目标示例&#xff1a;人生目标代码&#xff…

ubunut声卡配置 播放视频没有声音的解决方法 alsamixer和pavucontrol的使用方法

文章目录 &#x1f319;ubuntu22.04网页没有声音&#xff0c;声卡提示Dummy Output方法一&#xff1a;切换内核&#x1f319;方法二&#xff1a;使用知乎的方法 &#x1f319;ubuntu22.04 连接蓝牙耳机&#xff0c;1秒后断连解决方法ubuntu声音操作alsamixerpavucontrol通过are…

高校校园交友系统小程序的设计

管理员账户功能包括&#xff1a;系统首页&#xff0c;个人中心&#xff0c;管理员管理&#xff0c;用户管理&#xff0c;基础数据管理&#xff0c;论坛管理&#xff0c;公告信息管理&#xff0c;轮播图信息管理 微信端账号功能包括&#xff1a;系统首页&#xff0c;用户&#…

15分钟学 Python 第40天:Python 爬虫入门(六)第一篇

Day40 &#xff1a;Python 爬取豆瓣网前一百的电影信息 1. 项目背景 在这个项目中&#xff0c;我们将学习如何利用 Python 爬虫技术从豆瓣网抓取前一百部电影的信息。通过这一练习&#xff0c;您将掌握网页抓取的基本流程&#xff0c;包括发送请求、解析HTML、存储数据等核心…

【青训入营】青海湖租车之旅

# 问题描述油价飞升的今天&#xff0c;我们尽量减少花费。我们出门旅游&#xff0c;有时候租车去旅游也是一种不错的方式。这次我们这次旅游是从「青海湖」到「景点 X」&#xff0c;景点 X 可以是「敦煌」、「月牙泉」等&#xff0c;线路的路径是唯一的&#xff0c;假设我们每走…

佳易王电玩店ps5计时计费系统软件倒计时语音提醒软件操作教程

一、前言 【试用版软件下载可以点击最下方官网卡片】 佳易王电玩店ps5计时计费系统软件倒计时语音提醒软件操作教程 1、时间显示&#xff1a;正常使用时间&#xff0c;直观显示在对应桌旁。 2、倒计时显示&#xff1a;右侧显示剩余多少分钟&#xff0c; 3、定时语音提醒&am…