html烟花特效助力高考加油源码
时间: 2023-09-28 18:05:45 浏览: 294
好的,下面是一个使用 HTML、CSS 和 JavaScript 实现的烟花特效,希望它可以给你加油打气,让你在高考中取得好成绩!
```html
<!DOCTYPE html>
<html>
<head>
<title>高考加油!</title>
<meta charset="utf-8">
<style type="text/css">
body {
background-color: #f9f9f9;
font-family: Arial, sans-serif;
font-size: 16px;
color: #333;
}
#firework {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1;
}
.message {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
font-size: 36px;
z-index: 2;
}
</style>
</head>
<body>
<div id="firework"></div>
<div class="message">高考加油!</div>
<script type="text/javascript">
var container = document.getElementById("firework");
var colors = ["#ff0000", "#00ff00", "#0000ff", "#ffff00", "#ff00ff", "#00ffff"];
var size = 5;
function createFirework() {
var x = Math.random() * window.innerWidth;
var y = Math.random() * window.innerHeight;
var color = colors[Math.floor(Math.random() * colors.length)];
var firework = document.createElement("div");
firework.style.position = "absolute";
firework.style.width = size + "px";
firework.style.height = size + "px";
firework.style.borderRadius = size + "px";
firework.style.background = color;
firework.style.top = y + "px";
firework.style.left = x + "px";
container.appendChild(firework);
setTimeout(function() {
firework.remove();
}, 2000);
}
setInterval(createFirework, 100);
window.addEventListener("resize", function() {
container.style.height = window.innerHeight + "px";
});
</script>
</body>
</html>
```
该页面中有一个烟花特效和一个居中显示的文字“高考加油!”。烟花特效可以在页面中随机生成多个颜色不同的圆形,模拟出烟花爆炸的效果。希望这个页面可以给你带来一些放松和愉悦的感觉,让你心情愉快地参加高考,取得好成绩!
阅读全文