请使用html,css,js实现毕业典礼上的白玫瑰花,我需要源码
时间: 2024-03-06 17:49:38 浏览: 27
好的,以下是一个简单的实现白玫瑰花的 HTML、CSS 和 JavaScript 代码:
HTML 代码:
```html
<div class="flower">
<div class="petals"></div>
<div class="petals"></div>
<div class="petals"></div>
<div class="petals"></div>
<div class="petals"></div>
<div class="center"></div>
</div>
```
CSS 代码:
```css
.flower {
position: relative;
width: 100px;
height: 100px;
}
.petals {
position: absolute;
top: 50%;
left: 50%;
width: 20px;
height: 50px;
border-radius: 10px;
transform-origin: center bottom;
animation: petal 4s ease-in-out infinite;
}
.petals:nth-child(1) {
transform: translate(-25px, -50%) rotate(0deg);
}
.petals:nth-child(2) {
transform: translate(-25px, -50%) rotate(72deg);
}
.petals:nth-child(3) {
transform: translate(-25px, -50%) rotate(144deg);
}
.petals:nth-child(4) {
transform: translate(-25px, -50%) rotate(216deg);
}
.petals:nth-child(5) {
transform: translate(-25px, -50%) rotate(288deg);
}
@keyframes petal {
0% {
transform: translate(-25px, -50%) rotate(0deg);
}
50% {
transform: translate(-25px, -50%) rotate(30deg);
}
100% {
transform: translate(-25px, -50%) rotate(0deg);
}
}
.center {
position: absolute;
top: 50%;
left: 50%;
width: 20px;
height: 20px;
background-color: white;
border-radius: 50%;
}
```
JavaScript 代码:
```javascript
// 无需 JavaScript 代码
```
完整的 HTML 文件代码:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>白玫瑰花</title>
<style>
.flower {
position: relative;
width: 100px;
height: 100px;
}
.petals {
position: absolute;
top: 50%;
left: 50%;
width: 20px;
height: 50px;
border-radius: 10px;
transform-origin: center bottom;
animation: petal 4s ease-in-out infinite;
}
.petals:nth-child(1) {
transform: translate(-25px, -50%) rotate(0deg);
}
.petals:nth-child(2) {
transform: translate(-25px, -50%) rotate(72deg);
}
.petals:nth-child(3) {
transform: translate(-25px, -50%) rotate(144deg);
}
.petals:nth-child(4) {
transform: translate(-25px, -50%) rotate(216deg);
}
.petals:nth-child(5) {
transform: translate(-25px, -50%) rotate(288deg);
}
@keyframes petal {
0% {
transform: translate(-25px, -50%) rotate(0deg);
}
50% {
transform: translate(-25px, -50%) rotate(30deg);
}
100% {
transform: translate(-25px, -50%) rotate(0deg);
}
}
.center {
position: absolute;
top: 50%;
left: 50%;
width: 20px;
height: 20px;
background-color: white;
border-radius: 50%;
}
</style>
</head>
<body>
<div class="flower">
<div class="petals"></div>
<div class="petals"></div>
<div class="petals"></div>
<div class="petals"></div>
<div class="petals"></div>
<div class="center"></div>
</div>
</body>
</html>
```
你可以将这些代码复制到一个 HTML 文件中,然后在浏览器中打开这个文件,就可以看到一个简单的白玫瑰花了。