帮我用html写一个撒花代码
时间: 2023-04-10 10:03:17 浏览: 80
好的,以下是撒花代码的 HTML 实现:
```html
<!DOCTYPE html>
<html>
<head>
<title>撒花代码</title>
<style>
@keyframes sahua {
0% {
transform: scale(1);
opacity: 1;
}
50% {
transform: scale(2);
opacity: 0.5;
}
100% {
transform: scale(1);
opacity: 1;
}
}
.sahua {
display: inline-block;
animation: sahua 1s ease-in-out infinite;
}
</style>
</head>
<body>
<div class="sahua">❀</div>
</body>
</html>
```
你可以将以上代码保存为一个 HTML 文件,然后在浏览器中打开,就可以看到撒花效果了。
相关问题
帮我用HTML写一段撒花的代码
当用户点击按钮时,页面上会出现彩色的花瓣飘落,如下所示:
```html
<!DOCTYPE html>
<html>
<head>
<title>撒花</title>
<style>
body {
background-color: #f2f2f2;
}
#btn {
padding: 10px 20px;
background-color: #ff69b4;
color: #fff;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
}
#container {
position: relative;
height: 500px;
overflow: hidden;
}
.flower {
position: absolute;
width: 20px;
height: 20px;
background-color: #ff69b4;
border-radius: 50%;
animation: fall 5s linear infinite;
}
@keyframes fall {
0% {
top: -20px;
opacity: 1;
transform: scale(1);
}
100% {
top: 500px;
opacity: 0;
transform: scale(0.2);
}
}
</style>
</head>
<body>
<div id="container"></div>
<button id="btn">撒花</button>
<script>
var container = document.getElementById('container');
var btn = document.getElementById('btn');
btn.onclick = function() {
for (var i = 0; i < 50; i++) {
var flower = document.createElement('div');
flower.className = 'flower';
flower.style.left = Math.random() * container.offsetWidth + 'px';
container.appendChild(flower);
}
}
</script>
</body>
</html>
```
用c语言写一个撒花的代码
以下是用C语言编写的撒花代码:
```c
#include <stdio.h>
int main() {
printf("\\o/ \\o/ \\o/\n");
printf(" \\o\\ | /o/\n");
printf(" \\|/\n");
printf(" /|\\\n");
printf(" / | \\\n");
printf(" / | \\\n");
printf("/___|___\\\n");
return 0;
}
```
输出结果:
```
\o/ \o/ \o/
\o\ | /o/
\|/
/|\
/ | \
/ | \
/___|___\
```
这个代码会输出一个撒花的图案,可以在终端中运行。