上一篇
如何用html制作玫瑰花
- 行业动态
- 2024-03-26
- 6
制作玫瑰花的HTML代码如下:
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF8"> <meta name="viewport" content="width=devicewidth, initialscale=1.0"> <title>玫瑰花</title> <style> .rose { position: relative; width: 200px; height: 200px; backgroundcolor: red; borderradius: 50%; } .petal { position: absolute; width: 50px; height: 50px; backgroundcolor: pink; borderradius: 50%; } .petal:nthchild(odd) { top: 50%; left: 50%; transform: translate(50%, 50%) rotate(45deg); } .petal:nthchild(even) { top: 50%; left: 50%; transform: translate(50%, 50%) rotate(45deg); } </style> </head> <body> <div class="rose"> <div class="petal"></div> <div class="petal"></div> <div class="petal"></div> <div class="petal"></div> <div class="petal"></div> <div class="petal"></div> <div class="petal"></div> <div class="petal"></div> </div> </body> </html>
这段代码创建了一个简单的玫瑰花形状,使用CSS样式定义了玫瑰花和花瓣的外观,玫瑰花由一个红色的圆形表示,花瓣则是粉红色的圆形,通过调整花瓣的位置和旋转角度,可以形成玫瑰花的形状。